TIDE/backend/app/Post/PostModel.php
Yisroel Baum f73e5a1af5
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.
2026-05-06 22:28:45 +03:00

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',
];
}