# fluent-boards/1.45/app/Models/Label.php

FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration, version 1.45. 32 lines.

- Page: https://pluginprobe.com/plugins/fluent-boards/1.45/code/app/Models/Label.php
- Raw: https://pluginprobe.com/plugins/fluent-boards/1.45/raw/app/Models/Label.php
- Modified: 2024-05-31T06:41:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-boards/1.45/code/app/Models/Label.php#L10-L20`.

```php
<?php

namespace FluentBoards\App\Models;

use FluentBoards\App\Services\Constant;
use FluentBoards\Framework\Database\Orm\Builder;

class Label extends BoardTerm
{
    public static function boot()
    {
        parent::boot();
        static::creating(function ($model) {
            $model->type = $model->type ?: 'label'; // default type is label
        });

        static::addGlobalScope('type', function (Builder $builder) {
            $builder->where('type', '=', 'label');
        });
    }

    public function tasks()
    {
        return $this->belongsToMany(
            Task::class,
            'fbs_relations',
            'foreign_id',
            'object_id'
        )->withTimestamps()->wherePivot('object_type', Constant::OBJECT_TYPE_TASK_LABEL)->withPivot('settings', 'preferences');
    }
}

```
