<?php

namespace App\Repositories;

use App\Models\News;
use App\Traits\ImageTrait;
use Illuminate\Database\Eloquent\Model;

class NewsRepository extends BaseRepository
{
    use ImageTrait;

    public function __construct(News $model)
    {
        parent::__construct($model);
    }

    public function create(array $attributes): Model
    {
        $this->addImage($attributes, 'image', 'news');
        return parent::create($attributes);
    }

    public function update(Model $model, array $attributes): bool
    {
        $this->updateImage($attributes, 'image', 'news', $model);
        return parent::update($model, $attributes);
    }

    public function delete(Model $model, array $relations = []): array
    {
        $this->deleteImage($model, 'image');
        return parent::delete($model, $relations);
    }
}
