ImageFolder.php 894 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Longyi\ImageUpload\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class ImageFolder extends Model
  5. {
  6. /**
  7. * The table associated with the model.
  8. *
  9. * @var string
  10. */
  11. protected $table = 'image_folders';
  12. /**
  13. * The attributes that are mass assignable.
  14. *
  15. * @var array
  16. */
  17. protected $fillable = [
  18. 'name',
  19. 'parent_id',
  20. 'path',
  21. ];
  22. /**
  23. * Get the images in this folder.
  24. */
  25. public function images()
  26. {
  27. return $this->hasMany(ImageUpload::class, 'folder_id');
  28. }
  29. /**
  30. * Get the parent folder.
  31. */
  32. public function parent()
  33. {
  34. return $this->belongsTo(ImageFolder::class, 'parent_id');
  35. }
  36. /**
  37. * Get the child folders.
  38. */
  39. public function children()
  40. {
  41. return $this->hasMany(ImageFolder::class, 'parent_id');
  42. }
  43. }