Plan.php 841 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Models;
  3. use App\Models\Scopes\CompanyScope;
  4. use EloquentFilter\Filterable;
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. use Illuminate\Database\Eloquent\Model;
  7. class Plan extends Model
  8. {
  9. use HasFactory, Filterable;
  10. protected $fillable = [
  11. 'title',
  12. 'asset_id',
  13. 'parent_id',
  14. 'begin',
  15. 'end',
  16. 'description',
  17. ];
  18. public $timestamps = false;
  19. protected static function booted()
  20. {
  21. parent::booted(); // TODO: Change the autogenerated stub
  22. static::addGlobalScope(new CompanyScope);
  23. }
  24. public function requirements()
  25. {
  26. return $this->hasMany(Requirement::class);
  27. }
  28. public function projects()
  29. {
  30. return $this->belongsToMany(Project::class, 'project_plan', 'plan_id', 'project_id');
  31. }
  32. }