![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mcoil.corals.io/app/Http/Controllers/Admin/Towns/ |
<?php namespace App\Http\Controllers\Admin\Towns; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Shop\Towns\Town; use App\Shop\Counties\County; use Illuminate\Support\Facades\DB; class TownController extends Controller { /** * Display a listing of the county. * * @return \Illuminate\Http\Response */ public function index() { $town_list = DB::table('town') ->leftJoin('county', 'town.county_id', '=', 'county.id') ->select('town.id', 'county.name as county_name', 'town.name') ->orderBy('town.name', 'DESC') ->get(); return view('admin.town.list', ['towns' => $town_list]); } /** * Show the form for creating a new county. * * @return \Illuminate\Http\Response */ public function create() { $county_list = County::all(); return view('admin.town.create',['county_list'=>$county_list]); } /** * Store a newly created county in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $obj = new Town(); $obj->county_id = $request->county_id; $obj->name = $request->name; $obj->created_at = date("Y-m-d H:i:s"); $obj->save(); //$request->session()->flash('message', 'Town added successfully.'); return redirect()->route('admin.town.index')->with('message', 'Town added successfully.'); } // /** // * Display the specified resource. // * // * @param int $id // * @return \Illuminate\Http\Response // */ // public function show($id) // { // // // } // /** // * Show the form for editing the specified county. // * // * @param int $id // * @return \Illuminate\Http\Response // */ public function edit($id) { $town = Town::where('id',$id)->first(); $county_list = County::all(); return view('admin.town.edit',['county_list'=>$county_list,'town'=>$town]); } // /* // * Update the specified county in storage. // * // * @param \Illuminate\Http\Request $request // * @param int $id // * @return \Illuminate\Http\Response // */ public function update(Request $request, int $id) { $obj = Town::find($id); $obj->county_id = $request->county_id; $obj->name = $request->name; $obj->created_at = date("Y-m-d H:i:s"); $obj->save(); //$request->session()->flash('message', 'Town Updated successfully.'); return redirect()->route('admin.town.index')->with('message', 'Town updated successfully.'); } // /** // * Remove the specified County from storage. // * // * @param int $id // * @return \Illuminate\Http\Response // */ public function destroy(Request $request) { $id = $request->id; $town = Town::where('id', $id)->delete(); return redirect()->back(); } }