middleware(function ($request, $next) { //$this->user = Auth::guard('web')->user(); return $next($request); }); } /** * Display a listing of the resource. */ public function index(DirectoratDataTable $dataTable) { /*if (is_null($this->user) || !$this->user->can('masters.read')) { abort(403, 'Sorry !! You are Unauthorized to view any master data !'); }*/ return $dataTable->render('pages.masters.directorat.index'); } /** * Show the form for creating a new resource. */ public function create() { /*if (is_null($this->user) || !$this->user->can('masters.create')) { abort(403, 'Sorry !! You are Unauthorized to create any master data !'); }*/ return view('pages.masters.directorat.create'); } /** * Store a newly created resource in storage. */ public function store(StoreDirectoratRequest $request) { /*if (is_null($this->user) || !$this->user->can('masters.create')) { abort(403, 'Sorry !! You are Unauthorized to create any master data !'); }*/ // Validate the request... $validated = $request->validated(); // Store the Directorat... if($validated){ try{ Directorat::create($validated); return redirect()->route('directorat.index')->with('success', 'Directorat created successfully.'); }catch(\Exception $e){ return redirect()->route('directorat.index')->with('error', 'Directorat created failed.'); } } return false; } /** * Display the specified resource. */ public function show(Directorat $directorat) { // } /** * Show the form for editing the specified resource. */ public function edit($id) { $directorat = Directorat::find($id); return view('pages.masters.directorat.edit', compact('directorat')); } /** * Update the specified resource in storage. */ public function update(UpdateDirectoratRequest $request, Directorat $directorat) { /*if (is_null($this->user) || !$this->user->can('masters.update')) { abort(403, 'Sorry !! You are Unauthorized to update any master data !'); }*/ // Validate the request... $validated = $request->validated(); // Update the Directorat... if($validated){ try{ $directorat->update($validated); return redirect()->route('directorat.index')->with('success', 'Directorat updated successfully.'); }catch(\Exception $e){ return redirect()->route('directorat.index')->with('error', 'Directorat updated failed.'); } } return false; } /** * Remove the specified resource from storage. */ public function destroy(Directorat $directorat){ $directorat->delete(); return redirect()->route('directorat.index')->with('success', 'Directorat deleted successfully.'); } }