<?php

namespace DummyNamespace;

use DB;
use Carbon\Carbon;
use DummyModelNamespace;
use App\Exceptions\GeneralException;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;

/**
 * Class DummyRepoName.
 */
class DummyRepoName extends BaseRepository
{
    /**
     * Associated Repository Model.
     */
    const MODEL = dummy_model_name::class;

    /**
     * This method is used by Table Controller
     * For getting the table data to show in
     * the grid
     * @return mixed
     */
    public function getForDataTable()
    {
        return $this->query()
            ->select([
                config('module.model_small_plural.table').'.id',
                config('module.model_small_plural.table').'.created_at',
                config('module.model_small_plural.table').'.updated_at',
            ]);
    }
@startCreate
    /**
     * For Creating the respective model in storage
     *
     * @param array $input
     * @throws GeneralException
     * @return bool
     */
    public function create(array $input)
    {
        $dummy_small_model_name = self::MODEL;
        $dummy_small_model_name = new $dummy_small_model_name();
        if ($dummy_small_model_name->save($input)) {
            return true;
        }
        throw new GeneralException(trans('exceptions.backend.dummy_small_plural_model_name.create_error'));
    }
@endCreate@startEdit
    /**
     * For updating the respective Model in storage
     *
     * @param dummy_model_name $dummy_small_model_name
     * @param  $input
     * @throws GeneralException
     * return bool
     */
    public function update(dummy_model_name $dummy_small_model_name, array $input)
    {
    	if ($dummy_small_model_name->update($input))
            return true;

        throw new GeneralException(trans('exceptions.backend.dummy_small_plural_model_name.update_error'));
    }
@endEdit@startDelete
    /**
     * For deleting the respective model from storage
     *
     * @param dummy_model_name $dummy_small_model_name
     * @throws GeneralException
     * @return bool
     */
    public function delete(dummy_model_name $dummy_small_model_name)
    {
        if ($dummy_small_model_name->delete()) {
            return true;
        }

        throw new GeneralException(trans('exceptions.backend.dummy_small_plural_model_name.delete_error'));
    }@endDelete
}
