Initial commit
This commit is contained in:
26
app/Models/Image.php
Normal file
26
app/Models/Image.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user