Tutorial.php 916 B

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