73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Bo\DeliveryMode\UpdateDeliveryModeRequest;
|
|
use App\Models\Shop\DeliveryMode;
|
|
use Illuminate\Support\Str;
|
|
|
|
class DeliveryModeController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
$deliveryModes = DeliveryMode::paginate();
|
|
|
|
return view('back::pages.delivery-modes.index', compact('deliveryModes'));
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param \App\Models\Shop\DeliveryMode $deliveryMode
|
|
* @return \Illuminate\Http\Response
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
|
*/
|
|
public function edit(DeliveryMode $deliveryMode)
|
|
{
|
|
$this->authorize('update', DeliveryMode::class);
|
|
return view('back::pages.delivery-modes.edit', compact(
|
|
'deliveryMode'
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \App\Http\Requests\Bo\UpdateDeliveryModeRequest $request
|
|
* @param \App\Models\Shop\DeliveryMode $deliveryMode
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(UpdateDeliveryModeRequest $request, DeliveryMode $deliveryMode)
|
|
{
|
|
$this->authorize('update', DeliveryMode::class);
|
|
$deliveryMode->fill($request->validated());
|
|
if ($deliveryMode->saveOrFail()) {
|
|
return redirect()->back()
|
|
->with('bo.success', trans(
|
|
':model a été mis à jour',
|
|
['model' => Str::singular(trans('models.classes.delivery_modes'))]
|
|
));
|
|
}
|
|
return back();
|
|
}
|
|
|
|
/**
|
|
* Change model status
|
|
*
|
|
* @param DeliveryMode $model
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function changeStatus(DeliveryMode $model)
|
|
{
|
|
$this->authorize('update', DeliveryMode::class);
|
|
$model->status = !$model->status;
|
|
$model->saveOrFail();
|
|
return redirect()->back();
|
|
}
|
|
}
|