1
0
mirror of https://github.com/cp6/my-idlers.git synced 2024-11-18 00:13:12 +01:00
my-idlers/app/Http/Controllers/LocationsController.php
cp6 a314ac99ef Initial v2 commit
Initial v2 commit

Laravel project
2022-02-18 15:48:32 +11:00

46 lines
983 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Locations;
use Illuminate\Http\Request;
class LocationsController extends Controller
{
public function index()
{
$locations = Locations::all();
return view('locations.index', compact(['locations']));
}
public function create()
{
return view('locations.create');
}
public function store(Request $request)
{
$request->validate([
'location_name' => 'required|min:2'
]);
Locations::create([
'name' => $request->location_name
]);
return redirect()->route('locations.index')
->with('success', 'Location Created Successfully.');
}
public function destroy(Locations $location)
{
$items = Locations::find($location->id);
$items->delete();
return redirect()->route('locations.index')
->with('success', 'Location was deleted Successfully.');
}
}