| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace Longyi\ImageUpload\Models;
- use Illuminate\Database\Eloquent\Model;
- class ImageFolder extends Model
- {
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'image_folders';
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $fillable = [
- 'name',
- 'parent_id',
- 'path',
- ];
- /**
- * Get the images in this folder.
- */
- public function images()
- {
- return $this->hasMany(ImageUpload::class, 'folder_id');
- }
- /**
- * Get the parent folder.
- */
- public function parent()
- {
- return $this->belongsTo(ImageFolder::class, 'parent_id');
- }
- /**
- * Get the child folders.
- */
- public function children()
- {
- return $this->hasMany(ImageFolder::class, 'parent_id');
- }
- }
|