Files
Ronald Huynen 2547717edb Initial commit
2026-03-23 21:37:59 +01:00

27 lines
512 B
PHP

<?php
namespace App\Models;
use App\Models\Post;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
class Image extends Model
{
use HasFactory;
protected $fillable = ['path','position','caption'];
/**
* Get the related posts of the images
*
* @return void
*/
public function posts(): MorphToMany
{
return $this->morphedByMany(Post:: class, 'imageable');
}
}