Move model observers onto attributes and tidy provider bindings.
Register observers with ObservedBy, bind the comment spam classifier, and keep AppServiceProvider focused on application wiring.
This commit is contained in:
@@ -2,22 +2,25 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Observers\ArtworkFavouriteObserver;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Represents a user's "favourite" bookmark on an artwork.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $artwork_id
|
||||
* @property int|null $legacy_id Original favourite_id from the old site
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $artwork_id
|
||||
* @property int|null $legacy_id Original favourite_id from the old site
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property-read User $user
|
||||
* @property-read Artwork $artwork
|
||||
*/
|
||||
#[ObservedBy([ArtworkFavouriteObserver::class])]
|
||||
class ArtworkFavourite extends Model
|
||||
{
|
||||
protected $table = 'artwork_favourites';
|
||||
@@ -29,9 +32,9 @@ class ArtworkFavourite extends Model
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'integer',
|
||||
'user_id' => 'integer',
|
||||
'artwork_id' => 'integer',
|
||||
'legacy_id' => 'integer',
|
||||
'legacy_id' => 'integer',
|
||||
];
|
||||
|
||||
// ── Relations ──────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user