gallery support
This commit is contained in:
@@ -2,15 +2,18 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\HasGallery;
|
||||
use App\Traits\Uuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class Article extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Uuids;
|
||||
use HasGallery;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -29,6 +32,8 @@ class Article extends Model
|
||||
|
||||
/**
|
||||
* Get the article user
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
@@ -37,6 +42,8 @@ class Article extends Model
|
||||
|
||||
/**
|
||||
* Get all of the article's attachments.
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
*/
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
|
||||
45
app/Models/Gallery.php
Normal file
45
app/Models/Gallery.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Uuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class Gallery extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Uuids;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'media_id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Get gallery addendum model.
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Relations\MorphTo Addenum model.
|
||||
*/
|
||||
public function addendum(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the media for this item.
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Relations\BelongsTo The media model.
|
||||
*/
|
||||
public function media(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Media::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user