This commit is contained in:
Adrian Hopek
2022-05-17 11:38:16 +02:00
parent 45510a898b
commit d2babab7a0
17 changed files with 596 additions and 110 deletions

View File

@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace Toby\Infrastructure\Http\Controllers;
use Illuminate\Auth\Access\AuthorizationException;
use Inertia\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Toby\Eloquent\Models\Technology;
use Toby\Infrastructure\Http\Requests\TechnologyRequest;
use Toby\Infrastructure\Http\Resources\TechnologyResource;
class TechnologyController extends Controller
{
public function index(): Response
{
$this->authorize("manageResumes");
$technologies = Technology::query()
->orderBy("name")
->get();
return inertia("Technologies", [
"technologies" => TechnologyResource::collection($technologies),
]);
}
/**
* @throws AuthorizationException
*/
public function store(TechnologyRequest $request): RedirectResponse
{
$this->authorize("manageResumes");
$technology = Technology::query()->create($request->data());
return redirect()
->back()
->with("success", __("Technology :name has been created.", [
"name" => $technology->name,
]));
}
public function destroy(Technology $technology): RedirectResponse
{
$this->authorize("manageResumes");
$technology->delete();
return redirect()
->back()
->with("success", __("Technology :name has been deleted.", [
"name" => $technology->name,
]));
}
}