<?php

namespace App\Repositories\Admin;

use App\Models\CurrencyRate;
use InfyOm\Generator\Common\BaseRepository;

/**
 * Class CurrencyRateRepository
 * @package App\Repositories\Admin
 * @version December 8, 2021, 7:30 pm UTC
 *
 * @method CurrencyRate findWithoutFail($id, $columns = ['*'])
 * @method CurrencyRate find($id, $columns = ['*'])
 * @method CurrencyRate first($columns = ['*'])
*/
class CurrencyRateRepository extends BaseRepository
{
    /**
     * @var array
     */
    protected $fieldSearchable = [
        'id',
        'currency',
        'rate',
        'created_at',
        'updated_at',
        'deleted_at'
    ];

    /**
     * Configure the Model
     **/
    public function model()
    {
        return CurrencyRate::class;
    }

    /**
     * @param $request
     * @return mixed
     */
    public function saveRecord($request)
    {
        $input = $request->all();
        $currencyRate = $this->create($input);
        return $currencyRate;
    }

    /**
     * @param $request
     * @param $currencyRate
     * @return mixed
     */
    public function updateRecord($request, $currencyRate)
    {
        $input = $request->all();
        $currencyRate = $this->update($input, $currencyRate->id);
        return $currencyRate;
    }

    /**
     * @param $id
     * @return mixed
     */
    public function deleteRecord($id)
    {
        $currencyRate = $this->delete($id);
        return $currencyRate;
    }
}
