<?php

namespace App\Repositories\Admin;

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

/**
 * Class TeamRepository
 * @package App\Repositories\Admin
 * @version October 18, 2021, 9:37 pm UTC
 *
 * @method Team findWithoutFail($id, $columns = ['*'])
 * @method Team find($id, $columns = ['*'])
 * @method Team first($columns = ['*'])
 */
class TeamRepository extends BaseRepository
{
    /**
     * @var array
     */
    protected $fieldSearchable = [
        'id',
        'website_id',
        'name',
        'created_at'
    ];

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

    /**
     * @param $request
     * @return mixed
     */
    public function saveRecord($request)
    {
        $input = $request->all();
        $team  = $this->create($input);
        // $team->leads()->sync($input['lead_ids']);
        return $team;
    }

    /**
     * @param $request
     * @param $team
     * @return mixed
     */
    public function updateRecord($request, $team)
    {
        $input = $request->all();
        $team  = $this->update($input, $team->id);
        // $team->leads()->sync($input['lead_ids']);
        return $team;
    }

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