Tutorial.php 974 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Te7aHoudini\LaravelTrix\Traits\HasTrixRichText;
  5. use App\Traits\ModelTimeFormat;
  6. class Tutorial extends Model
  7. {
  8. use ModelTimeFormat;
  9. use HasTrixRichText;
  10. protected $guarded=[];
  11. protected $fillable=[
  12. 'owner_id','name','type'
  13. ];
  14. protected $appends=[
  15. 'owner_name'
  16. ];
  17. public function owner(){
  18. return $this->belongsTo('App\Owner','owner_id','id');
  19. }
  20. public function trixRichText(){
  21. return $this->belongsTo('Te7aHoudini\LaravelTrix\Models\TrixRichText','id','model_id');
  22. }
  23. public function trixAttachments()
  24. {
  25. return $this->hasMany('Te7aHoudini\LaravelTrix\Models\TrixAttachment','attachable_id','id');
  26. }
  27. public function processes(){
  28. return $this->belongsToMany('App\Process');
  29. }
  30. public function getOwnerNameAttribute()
  31. {
  32. return $this['owner']? $this['owner']['name']:null;
  33. }
  34. }