109 lines
3 KiB
PHP
109 lines
3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Bo\Networks\StoreNetwork;
|
|
use App\Http\Requests\Bo\Networks\UpdateNetwork;
|
|
use App\Http\Requests\ValidateOtpRequest;
|
|
use App\Models\Network;
|
|
|
|
class NetworkController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
$networks = Network::paginate(20);
|
|
return view('bo.pages.networks.index', compact('networks'));
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create()
|
|
{
|
|
return view('bo.pages.networks.create');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \App\Http\Requests\Networks\StoreNetwork $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(StoreNetwork $request)
|
|
{
|
|
$network = new Network();
|
|
$network->fill($request->validated());
|
|
if ($network->saveOrFail()) {
|
|
return redirect()->route('bo.networks.edit', compact('network'))
|
|
->with('success', trans('Network créé.'));
|
|
}
|
|
|
|
return \back();
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param \App\Models\Network $network
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit(Network $network)
|
|
{
|
|
return view('bo.pages.networks.edit', ['network' => $network]);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \App\Http\Requests\Networks\UpdateNetwork $request
|
|
* @param \App\Models\Network $network
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(UpdateNetwork $request, Network $network)
|
|
{
|
|
$network->fill($request->validated());
|
|
if ($network->saveOrFail()) {
|
|
return redirect()->route('bo.networks.edit', compact('network'))
|
|
->with('success', trans('Network mis à jour.'));
|
|
}
|
|
return \back();
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Models\Network $network
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(Network $network)
|
|
{
|
|
return view('bo.pages.networks.delete', ['network' => $network]);
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Http\Requests\ValidateOtpRequest $request
|
|
* @param \App\Models\Network $network
|
|
* @return \Illuminate\Http\Response
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
|
*/
|
|
public function destroySubmit(ValidateOtpRequest $request, Network $network)
|
|
{
|
|
// phpcs:enable
|
|
if ($network->deleteOrFail()) {
|
|
return redirect()->route('bo.networks.index')
|
|
->with('warning', 'Network supprimé !');
|
|
}
|
|
|
|
return back();
|
|
}
|
|
}
|