- add messages
This commit is contained in:
parent
af3aa905bd
commit
d47c719d13
@ -25,10 +25,12 @@ class ProjectController
|
||||
public function update(ProjectRequest $request, Project $project): RedirectResponse
|
||||
{
|
||||
if ($this->projectRepository->update($project, $request->validated())) {
|
||||
return back()->with('message', 'Zaktualizowano projekt!');
|
||||
return back()
|
||||
->with('success', 'Zaktualizowano projekt!');
|
||||
}
|
||||
|
||||
return back()->withError(['message_error', 'Wystąpił błąd podczas aktualizacji!']);
|
||||
return back()
|
||||
->with(['error', 'Wystąpił błąd podczas aktualizacji!']);
|
||||
}
|
||||
|
||||
public function create(): InertiaResponse
|
||||
@ -42,10 +44,10 @@ class ProjectController
|
||||
if ($project = $this->projectRepository->create($validated)) {
|
||||
return redirect()
|
||||
->route('admin.project.update', compact('project'))
|
||||
->with('message', 'Utworzono projekt!');
|
||||
->with('success', 'Utworzono projekt!');
|
||||
}
|
||||
|
||||
return back()->withError(['message_error', 'Wystąpił błąd podczas tworzenia!']);
|
||||
return back()->withError(['error', 'Wystąpił błąd podczas tworzenia!']);
|
||||
}
|
||||
|
||||
public function delete(Project $project): InertiaResponse
|
||||
@ -57,7 +59,9 @@ class ProjectController
|
||||
{
|
||||
$title = $project->title;
|
||||
$project->delete();
|
||||
return redirect()->route('admin.home')->with('message', 'Usunięto projekt "'. $title .'"');
|
||||
return redirect()
|
||||
->route('admin.home')
|
||||
->with('info', 'Usunięto projekt "'. $title .'"');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
<script setup>
|
||||
|
||||
defineProps({
|
||||
messages: {
|
||||
type: Object,
|
||||
default: {},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
@ -27,6 +32,15 @@
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
<div v-if="messages?.info" class="max-w-screen-lg mx-2 lg:mx-auto mt-2 px-2 py-3 rounded-md bg-yellow-100 text-yellow-600 text-center">
|
||||
{{ messages.info }}
|
||||
</div>
|
||||
<div v-if="messages?.error" class="max-w-screen-lg mx-2 lg:mx-auto mt-2 px-2 py-3 rounded-md bg-red-100 text-red-600 text-center">
|
||||
{{ messages.error }}
|
||||
</div>
|
||||
<div v-if="messages?.success" class="max-w-screen-lg mx-2 lg:mx-auto mt-2 px-2 py-3 rounded-md bg-green-100 text-green-600 text-center">
|
||||
{{ messages?.success }}
|
||||
</div>
|
||||
<main class="max-w-screen-lg mx-2 lg:mx-auto mt-2 rounded-md bg-gray-50">
|
||||
<slot />
|
||||
</main>
|
||||
|
@ -17,21 +17,20 @@ defineProps({
|
||||
<li
|
||||
v-for="(project, key) in projects"
|
||||
:key="key"
|
||||
class="flex items-center justify-between px-3 py-2 bg-white hover:bg-neutral-200"
|
||||
>
|
||||
<div class="flex items-center justify-between px-3 py-2 bg-white hover:bg-neutral-200">
|
||||
<InertiaLink :href="`/dashboard/project/${project.id}`">{{ project.title }}</InertiaLink>
|
||||
<div class="flex items-center gap-2">
|
||||
<InertiaLink
|
||||
as="button"
|
||||
class="px-2 py-1 text-lime-600 hover:text-lime-800 border-t-2 border-b-2 border-transparent hover:border-b-lime-600"
|
||||
:href="`/dashboard/project/${project.id}`"
|
||||
title="Edytuj projekt"><FontAwesomeIcon :icon="['fas', 'pen-to-square']" /></InertiaLink>
|
||||
<InertiaLink
|
||||
as="button"
|
||||
class="px-2 py-1 text-red-600 hover:text-red-800"
|
||||
:href="`/dashboard/project/${project.id}/delete`"
|
||||
title="Usuń projekt z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink>
|
||||
</div>
|
||||
<InertiaLink :href="`/dashboard/project/${project.id}`">{{ project.title }}</InertiaLink>
|
||||
<div class="flex items-center gap-2">
|
||||
<InertiaLink
|
||||
as="button"
|
||||
class="px-2 py-1 text-lime-600 hover:text-lime-800 border-t-2 border-b-2 border-transparent hover:border-b-lime-600"
|
||||
:href="`/dashboard/project/${project.id}`"
|
||||
title="Edytuj projekt"><FontAwesomeIcon :icon="['fas', 'pen-to-square']" /></InertiaLink>
|
||||
<InertiaLink
|
||||
as="button"
|
||||
class="px-2 py-1 text-red-600 hover:text-red-800"
|
||||
:href="`/dashboard/project/${project.id}/delete`"
|
||||
title="Usuń projekt z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user