12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace App\Models;
- use App\Models\Scopes\CompanyScope;
- use EloquentFilter\Filterable;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class Plan extends Model
- {
- use HasFactory, Filterable,SoftDeletes;
- protected $fillable = [
- 'title',
- 'asset_id',
- 'parent_id',
- 'begin',
- 'end',
- 'description',
- ];
- protected static function booted()
- {
- parent::booted(); // TODO: Change the autogenerated stub
- static::addGlobalScope(new CompanyScope);
- }
- public function requirements()
- {
- return $this->hasMany(Requirement::class);
- }
- public function projects()
- {
- return $this->belongsToMany(Project::class, 'project_plan', 'plan_id', 'project_id');
- }
- public function children()
- {
- return $this->hasMany(Plan::class, 'parent_id');
- }
- public function asset(){
- return $this->belongsTo(Asset::class);
- }
- }
|