관리-도구
편집 파일: ChiarmanInterviewController.php
<?php namespace App\Http\Controllers; use Auth; use Illuminate\Support\Str; use Illuminate\Http\Request; use App\Models\ChiarmanInterview; use Illuminate\Support\Facades\DB; class ChiarmanInterviewController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ protected $folder_name = "backend.chiarman."; public function index() { $chiarmanInterviews = ChiarmanInterview::orderByDesc('created_at')->get(); $data = [ 'chiarmanInterviews'=>$chiarmanInterviews ]; return view($this->folder_name.'index', $data); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view($this->folder_name.'create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { DB::beginTransaction(); try { $input = $request->all(); $input['user_id']=Auth::id(); $input['slug']=Str::slug($request->title. rand(00000, 99999)); ChiarmanInterview::create($input); DB::commit(); return redirect()->route('chiarmanInterview.index'); } catch (\Throwable $th) { DB::rollBack(); return back()->withInput(); } } /** * Display the specified resource. * * @param \App\Models\ChiarmanInterview $chiarmanInterview * @return \Illuminate\Http\Response */ public function show(ChiarmanInterview $chiarmanInterview) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\ChiarmanInterview $chiarmanInterview * @return \Illuminate\Http\Response */ public function edit(ChiarmanInterview $chiarmanInterview) { $data = [ 'chiarmanInterview'=>$chiarmanInterview, ]; return view($this->folder_name.'edit', $data); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\ChiarmanInterview $chiarmanInterview * @return \Illuminate\Http\Response */ public function update(Request $request, ChiarmanInterview $chiarmanInterview) { $input = $request->all(); DB::beginTransaction(); try { $chiarmanInterview->update($input); DB::commit(); return redirect()->route('chiarmanInterview.index'); } catch (\Throwable $th) { DB::rollBack(); return back()->withInput(); } } /** * Remove the specified resource from storage. * * @param \App\Models\ChiarmanInterview $chiarmanInterview * @return \Illuminate\Http\Response */ public function destroy(ChiarmanInterview $chiarmanInterview) { $chiarmanInterview->delete(); return back()->with("succesfully Deleted"); } }