mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-18 00:13:12 +01:00
a314ac99ef
Initial v2 commit Laravel project
46 lines
983 B
PHP
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.');
|
|
}
|
|
}
|