Tutorial.php 1.0 KB

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