extend Post entity with feature slot

Adds nullable feature_slot column (unique) plus repo
findByFeatureSlot/findFeatured/update methods so admins can
pin a post into one of two slots.
This commit is contained in:
Yisroel Baum 2026-05-06 22:28:45 +03:00
parent 64a334c63e
commit f73e5a1af5
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
6 changed files with 160 additions and 4 deletions

View file

@ -2,22 +2,27 @@
namespace App\Post;
use DateTimeImmutable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
/**
* @property int $id
* @property int $user_id
* @property string $title
* @property string $body
* @property Carbon $created_at
* @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
*/
@ -32,9 +37,11 @@ class PostModel extends Model
'title',
'body',
'created_at',
'feature_slot',
];
protected $casts = [
'created_at' => 'datetime',
'created_at' => 'immutable_datetime',
'feature_slot' => 'integer',
];
}