Controller.stub 3.56 KB
Newer Older
Viral Solani's avatar
Viral Solani committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
<?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
}