<?php

namespace DummyNamespace;

use DummyModelNamespace;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DummyRepositoryNamespace;
use DummyManageRequestNamespace;
@Namespaces
/**
 * DummyController
 */
class DummyController extends Controller
{
    /**
     * variable to store the repository object
     * @var dummy_repository
     */
    protected $repository;

    /**
     * contructor to initialize repository object
     * @param dummy_repository $repository;
     */
    public function __construct(dummy_repository $repository)
    {
        $this->repository = $repository;
    }

    /**
     * Display a listing of the resource.
     *
     * @param  DummyManageRequestNamespace  $request
     * @return \Illuminate\Http\Response
     */
    public function index(DummyManageRequest $request)
    {
        return view('backend.dummy_small_plural_model.index');
    }
    @startCreate/**
     * Show the form for creating a new resource.
     *
     * @param  DummyCreateRequestNamespace  $request
     * @return \Illuminate\Http\Response
     */
    public function create(DummyCreateRequest $request)
    {
        return view('backend.dummy_small_plural_model.create');
    }
    /**
     * Store a newly created resource in storage.
     *
     * @param  DummyStoreRequestNamespace  $request
     * @return \Illuminate\Http\Response
     */
    public function store(DummyStoreRequest $request)
    {
        //Input received from the request
        $input = $request->except(['_token']);
        //Create the model using repository create method
        $this->repository->create($input);
        //return with successfull message
        return redirect()->route('admin.dummy_small_plural_model.index')->withFlashSuccess(trans('alerts.backend.dummy_small_plural_model.created'));
    }
    @endCreate@startEdit/**
     * Show the form for editing the specified resource.
     *
     * @param  DummyModelNamespace  $DummyArgumentName
     * @param  DummyEditRequestNamespace  $request
     * @return \Illuminate\Http\Response
     */
    public function edit(DummyModel $DummyArgumentName, DummyEditRequest $request)
    {
        return view('backend.dummy_small_plural_model.edit', compact('DummyArgumentName'));
    }
    /**
     * Update the specified resource in storage.
     *
     * @param  DummyUpdateRequestNamespace  $request
     * @param  DummyModelNamespace  $DummyArgumentName
     * @return \Illuminate\Http\Response
     */
    public function update(DummyUpdateRequest $request, DummyModel $DummyArgumentName)
    {
        //Input received from the request
        $input = $request->except(['_token']);
        //Update the model using repository update method
        $this->repository->update( $DummyArgumentName, $input );
        //return with successfull message
        return redirect()->route('admin.dummy_small_plural_model.index')->withFlashSuccess(trans('alerts.backend.dummy_small_plural_model.updated'));
    }
    @endEdit@startDelete/**
     * Remove the specified resource from storage.
     *
     * @param  DummyDeleteRequestNamespace  $request
     * @param  DummyModelNamespace  $DummyArgumentName
     * @return \Illuminate\Http\Response
     */
    public function destroy(DummyModel $DummyArgumentName, DummyDeleteRequest $request)
    {
        //Calling the delete method on repository
        $this->repository->delete($DummyArgumentName);
        //returning with successfull message
        return redirect()->route('admin.dummy_small_plural_model.index')->withFlashSuccess(trans('alerts.backend.dummy_small_plural_model.deleted'));
    }
    @endDelete
}
