2020-04-17 09:18:42 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
2022-06-15 12:07:34 +02:00
|
|
|
use App\Http\Requests\DatastorePccs\StoreDatastorePccRequest;
|
|
|
|
|
use App\Http\Requests\DatastorePccs\UpdateDatastorePccRequest;
|
|
|
|
|
use App\Http\Requests\ValidateOtpRequest;
|
2020-04-17 09:18:42 +02:00
|
|
|
use App\Models\DatastorePcc;
|
2022-06-13 17:40:44 +02:00
|
|
|
use App\Models\Server;
|
2020-04-17 09:18:42 +02:00
|
|
|
|
|
|
|
|
class DatastorePCCController extends Controller
|
|
|
|
|
{
|
2022-06-15 12:07:34 +02:00
|
|
|
/**
|
|
|
|
|
* Display a listing of the resource.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
2022-06-13 15:49:59 +02:00
|
|
|
{
|
2022-06-15 12:07:34 +02:00
|
|
|
$datastore_pccs = DatastorePcc::all();
|
|
|
|
|
return view('datastore_pccs.index', ['datastore_pccs' => $datastore_pccs]);
|
2020-04-17 09:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-15 12:07:34 +02:00
|
|
|
/**
|
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function create()
|
2022-06-13 15:49:59 +02:00
|
|
|
{
|
2022-06-15 12:07:34 +02:00
|
|
|
return view('datastore_pccs.create');
|
2020-04-17 09:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-15 12:07:34 +02:00
|
|
|
/**
|
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Http\Requests\DatastorePccs\StoreDatastorePccRequest $request
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function store(StoreDatastorePccRequest $request)
|
2022-06-13 15:49:59 +02:00
|
|
|
{
|
2022-06-15 12:07:34 +02:00
|
|
|
$datastore_pcc = new DatastorePcc();
|
|
|
|
|
$datastore_pcc->fill($request->validated());
|
|
|
|
|
if ($datastore_pcc->saveOrFail()) {
|
|
|
|
|
return redirect()->route('datastore_pccs.edit', compact('datastore_pcc'))
|
|
|
|
|
->with('success', trans('Datastore Pcc créé créé.'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return \back();
|
2020-04-17 09:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-15 12:07:34 +02:00
|
|
|
/**
|
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\DatastorePcc $datastore_pcc
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function edit(DatastorePcc $datastore_pcc)
|
2022-06-13 15:49:59 +02:00
|
|
|
{
|
2022-06-15 12:07:34 +02:00
|
|
|
return view('datastore_pccs.edit', ['datastore_pcc' => $datastore_pcc]);
|
2020-04-17 09:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-15 12:07:34 +02:00
|
|
|
/**
|
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Http\Requests\DatastorePccs\UpdateDatastorePccRequest $request
|
|
|
|
|
* @param \App\Models\DatastorePcc $datastore_pcc
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function update(UpdateDatastorePccRequest $request, DatastorePcc $datastore_pcc)
|
2022-06-13 15:49:59 +02:00
|
|
|
{
|
2022-06-15 12:07:34 +02:00
|
|
|
$datastore_pcc->fill($request->validated());
|
|
|
|
|
if ($datastore_pcc->saveOrFail()) {
|
|
|
|
|
return redirect()->route('datastore_pccs.edit', compact('datastore_pcc'))
|
|
|
|
|
->with('success', trans('Datastore Pcc mis à jour.'));
|
|
|
|
|
}
|
|
|
|
|
return \back();
|
2020-04-17 09:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-15 12:07:34 +02:00
|
|
|
/**
|
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\DatastorePcc $datastore_pcc
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function destroy(DatastorePcc $datastore_pcc)
|
2022-06-13 15:49:59 +02:00
|
|
|
{
|
2022-06-15 12:07:34 +02:00
|
|
|
$isUsed = Server::where('datastore_pcc_id', '=', $datastore_pcc->id)->get();
|
2022-06-13 15:49:59 +02:00
|
|
|
if ($isUsed->count() === 0) {
|
2020-04-17 09:18:42 +02:00
|
|
|
$isUsed = false;
|
2022-06-13 15:49:59 +02:00
|
|
|
}
|
2020-04-17 09:18:42 +02:00
|
|
|
|
2022-06-15 12:07:34 +02:00
|
|
|
return view('datastore_pccs.delete', compact('datastore_pcc', 'isUsed'));
|
2020-04-17 09:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-15 12:07:34 +02:00
|
|
|
/**
|
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Http\Requests\ValidateOtpRequest $request
|
|
|
|
|
* @param \App\Models\DatastorePcc $datastore_pcc
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
|
|
|
|
*/
|
|
|
|
|
public function destroySubmit(ValidateOtpRequest $request, DatastorePcc $datastore_pcc)
|
2020-04-17 09:18:42 +02:00
|
|
|
{
|
2022-06-15 12:07:34 +02:00
|
|
|
// phpcs:enable
|
|
|
|
|
if ($datastore_pcc->deleteOrFail()) {
|
|
|
|
|
return redirect()->route('datastore_pccs.index')
|
|
|
|
|
->with('warning', 'Datastore Pcc supprimée !');
|
2020-04-17 09:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-15 12:07:34 +02:00
|
|
|
return back();
|
2020-04-17 09:18:42 +02:00
|
|
|
}
|
|
|
|
|
}
|