59 lines
1.5 KiB
PHP
59 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Inventory;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Inventory\StoreLocationRequest;
|
|
use App\Http\Requests\Inventory\UpdateLocationRequest;
|
|
use App\Models\Location;
|
|
|
|
class LocationController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
return view('admin.inventory.locations.index', [
|
|
'values' => Location::query()->orderBy('name')->get(),
|
|
]);
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
return view('admin.inventory.locations.form', [
|
|
'model' => new Location(['active' => true]),
|
|
]);
|
|
}
|
|
|
|
public function store(StoreLocationRequest $request)
|
|
{
|
|
Location::create($request->validated());
|
|
|
|
\Session::flash('alert-save', '1');
|
|
|
|
return redirect()->route('admin.inventory.locations.index');
|
|
}
|
|
|
|
public function edit(Location $location)
|
|
{
|
|
return view('admin.inventory.locations.form', [
|
|
'model' => $location,
|
|
]);
|
|
}
|
|
|
|
public function update(UpdateLocationRequest $request, Location $location)
|
|
{
|
|
$location->update($request->validated());
|
|
|
|
\Session::flash('alert-save', '1');
|
|
|
|
return redirect()->route('admin.inventory.locations.index');
|
|
}
|
|
|
|
public function destroy(Location $location)
|
|
{
|
|
$location->delete();
|
|
|
|
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
|
|
|
return redirect()->route('admin.inventory.locations.index');
|
|
}
|
|
}
|