Plan.php 715 B

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