e3da625927
- Backend Laravel 11 (API REST, JWT auth, PostgreSQL) - Frontend Next.js 14 (React, TypeScript, Tailwind CSS) - Docker Compose (PostgreSQL, backend, frontend) - Modules : auth, profil, tracker émotions, informations, admin
48 lines
949 B
PHP
48 lines
949 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Feed extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'feeds';
|
|
|
|
protected $fillable = [
|
|
'titre',
|
|
'slug',
|
|
'contenu',
|
|
'image_url',
|
|
'est_publie',
|
|
'auteur_id',
|
|
'ordre',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'est_publie' => 'boolean',
|
|
'ordre' => 'integer',
|
|
];
|
|
}
|
|
|
|
// ──── Relations ────
|
|
|
|
public function auteur(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Utilisateur::class, 'auteur_id');
|
|
}
|
|
|
|
// ──── Scopes ────
|
|
|
|
public function scopePublie(Builder $query): Builder
|
|
{
|
|
return $query->where('est_publie', true);
|
|
}
|
|
}
|