Viewing file: StateController.php (2.54 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace App\Http\Controllers\Back;
use App\{ Models\State, Http\Requests\StateRequest, Http\Controllers\Controller };
class StateController extends Controller { /** * Constructor Method. * * Setting Authentication */ public function __construct() { $this->middleware('auth:admin'); $this->middleware('adminlocalize'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return view('back.state.index',[ 'datas' => State::orderBy('id','desc')->get() ]); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('back.state.create'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(StateRequest $request) {
State::create($request->all()); return redirect()->route('back.state.index')->withSuccess(__('New State Added Successfully.')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit(State $state) { return view('back.state.edit',compact('state')); }
/** * Change the status for editing the specified resource. * * @param int $id * @param int $status * @return \Illuminate\Http\Response */ public function status($id,$status) { State::find($id)->update(['status' => $status]); return redirect()->route('back.state.index')->withSuccess(__('Status Updated Successfully.')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(StateRequest $request, State $state) { $state->update($request->all()); return redirect()->route('back.state.index')->withSuccess(__('State Updated Successfully.')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(State $state) { $state->delete(); return redirect()->route('back.state.index')->withSuccess(__('State Deleted Successfully.')); } }
|