Adds nullable feature_slot column (unique) plus repo findByFeatureSlot/findFeatured/update methods so admins can pin a post into one of two slots.
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Post;
|
|
|
|
use DateTimeImmutable;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property int $user_id
|
|
* @property string $title
|
|
* @property string $body
|
|
* @property DateTimeImmutable $created_at
|
|
* @property ?int $feature_slot
|
|
*
|
|
* @method static Builder<static>|PostModel newModelQuery()
|
|
* @method static Builder<static>|PostModel newQuery()
|
|
* @method static Builder<static>|PostModel query()
|
|
* @method static Builder<static>|PostModel whereId($value)
|
|
* @method static Builder<static>|PostModel whereUserId($value)
|
|
* @method static Builder<static>|PostModel whereTitle($value)
|
|
* @method static Builder<static>|PostModel whereBody($value)
|
|
* @method static Builder<static>|PostModel whereCreatedAt($value)
|
|
* @method static Builder<static>|PostModel whereFeatureSlot($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class PostModel extends Model
|
|
{
|
|
protected $table = 'posts';
|
|
|
|
public $timestamps = false;
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'title',
|
|
'body',
|
|
'created_at',
|
|
'feature_slot',
|
|
];
|
|
|
|
protected $casts = [
|
|
'created_at' => 'immutable_datetime',
|
|
'feature_slot' => 'integer',
|
|
];
|
|
}
|