toby/app/Infrastructure/Http/Controllers/TechnologyController.php
Adrian Hopek 431262dfb7
#134 - fill users data for resume (#144)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* lint fixes

* missing empty lines

* translations

* fix vue version

* #134 - fixes

* fix

* fix

* #134 - fix

* fix

* fix

* #134 - added tests

* #134 - fix to translations

* #134 - tests

* #134 - fix

* Update database/factories/ResumeFactory.php

Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com>

* #134 - fix

* #134 - fix

Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com>
2022-05-18 08:50:41 +02:00

58 lines
1.5 KiB
PHP

<?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,
]));
}
}