Skip to content

Commit ffc9415

Browse files
committed
Created permission create and update pages
1 parent d77a9c4 commit ffc9415

File tree

5 files changed

+351
-3
lines changed

5 files changed

+351
-3
lines changed

app/Http/Controllers/Admin/PermissionController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ public function store(StorePermissionRequest $request)
8282
*/
8383
public function show(Permission $permission)
8484
{
85-
return view('admin.permission.show', compact('permission'));
85+
return Inertia::render('Admin/Permission/Show', [
86+
'permission' => $permission,
87+
]);
8688
}
8789

8890
/**
@@ -94,7 +96,7 @@ public function show(Permission $permission)
9496
public function edit(Permission $permission)
9597
{
9698
return Inertia::render('Admin/Permission/Edit', [
97-
'permission' => $permission
99+
'permission' => $permission,
98100
]);
99101
}
100102

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<script setup>
2+
import BreezeAuthenticatedLayout from "@/Layouts/Authenticated.vue";
3+
import { Head, Link, useForm } from "@inertiajs/inertia-vue3";
4+
import BreezeButton from "@/Components/Button.vue";
5+
6+
const form = useForm({
7+
name: '',
8+
});
9+
</script>
10+
11+
<template>
12+
<Head title="Create permission" />
13+
14+
<BreezeAuthenticatedLayout>
15+
<template #header>
16+
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
17+
Permissions
18+
</h2>
19+
</template>
20+
21+
<div class="py-12">
22+
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
23+
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
24+
<div class="p-6 bg-white border-b border-gray-200">
25+
<div class="flex flex-col">
26+
<div>
27+
<h1
28+
class="
29+
inline-block
30+
text-2xl
31+
sm:text-3xl
32+
font-extrabold
33+
text-slate-900
34+
tracking-tight
35+
dark:text-slate-200
36+
py-4
37+
block
38+
sm:inline-block
39+
flex
40+
"
41+
>
42+
Create permission
43+
</h1>
44+
<Link
45+
:href="route('permission.index')"
46+
class="
47+
no-underline
48+
hover:underline
49+
text-cyan-600
50+
dark:text-cyan-400
51+
"
52+
>&lt;&lt; Back to all permissions</Link
53+
>
54+
</div>
55+
<div class="w-full py-2 bg-white overflow-hidden">
56+
<form @submit.prevent="form.post(route('permission.store'))">
57+
<div class="py-2">
58+
<label
59+
class="block font-bold text-sm text-gray-700"
60+
:class="{ 'text-red-400': form.errors.name }"
61+
for="name"
62+
>
63+
Name
64+
</label>
65+
66+
<input
67+
class="
68+
my-2
69+
rounded-md
70+
shadow-sm
71+
border-gray-300
72+
focus:border-indigo-300
73+
focus:ring
74+
focus:ring-indigo-200
75+
focus:ring-opacity-50
76+
block
77+
w-full
78+
"
79+
:class="{ 'border-red-400': form.errors.name }"
80+
id="name"
81+
type="text"
82+
v-model="form.name"
83+
/>
84+
<div class="text-red-400 text-sm" v-if="form.errors.name">
85+
{{ form.errors.name }}
86+
</div>
87+
</div>
88+
89+
<div class="flex justify-end mt-4">
90+
<BreezeButton
91+
class="ml-4"
92+
:class="{ 'opacity-25': form.processing }"
93+
:disabled="form.processing"
94+
>
95+
Create
96+
</BreezeButton>
97+
</div>
98+
</form>
99+
</div>
100+
</div>
101+
</div>
102+
</div>
103+
</div>
104+
</div>
105+
</BreezeAuthenticatedLayout>
106+
</template>
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<script setup>
2+
import BreezeAuthenticatedLayout from "@/Layouts/Authenticated.vue";
3+
import { Head, Link, useForm } from "@inertiajs/inertia-vue3";
4+
import BreezeButton from "@/Components/Button.vue";
5+
6+
const props = defineProps({
7+
permission: {
8+
type: Object,
9+
default: () => ({}),
10+
},
11+
});
12+
13+
const form = useForm({
14+
_method: 'put',
15+
name: props.permission.name,
16+
});
17+
</script>
18+
19+
<template>
20+
<Head title="Update permission" />
21+
22+
<BreezeAuthenticatedLayout>
23+
<template #header>
24+
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
25+
Permissions
26+
</h2>
27+
</template>
28+
29+
<div class="py-12">
30+
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
31+
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
32+
<div class="p-6 bg-white border-b border-gray-200">
33+
<div class="flex flex-col">
34+
<div>
35+
<h1
36+
class="
37+
inline-block
38+
text-2xl
39+
sm:text-3xl
40+
font-extrabold
41+
text-slate-900
42+
tracking-tight
43+
dark:text-slate-200
44+
py-4
45+
block
46+
sm:inline-block
47+
flex
48+
"
49+
>
50+
Update permission
51+
</h1>
52+
<Link
53+
:href="route('permission.index')"
54+
class="
55+
no-underline
56+
hover:underline
57+
text-cyan-600
58+
dark:text-cyan-400
59+
"
60+
>&lt;&lt; Back to all permissions</Link
61+
>
62+
</div>
63+
<div class="w-full py-2 bg-white overflow-hidden">
64+
<form
65+
@submit.prevent="
66+
form.post(route('permission.update', this.permission.id))
67+
"
68+
>
69+
<div class="py-2">
70+
<label
71+
class="block font-bold text-sm text-gray-700"
72+
:class="{ 'text-red-400': form.errors.name }"
73+
for="name"
74+
>
75+
Name
76+
</label>
77+
78+
<input
79+
class="
80+
my-2
81+
rounded-md
82+
shadow-sm
83+
border-gray-300
84+
focus:border-indigo-300
85+
focus:ring
86+
focus:ring-indigo-200
87+
focus:ring-opacity-50
88+
block
89+
w-full
90+
"
91+
:class="{ 'border-red-400': form.errors.name }"
92+
id="name"
93+
type="text"
94+
v-model="form.name"
95+
/>
96+
<div class="text-red-400 text-sm" v-if="form.errors.name">
97+
{{ form.errors.name }}
98+
</div>
99+
</div>
100+
101+
<div class="flex justify-end mt-4">
102+
<BreezeButton
103+
class="ml-4"
104+
:class="{ 'opacity-25': form.processing }"
105+
:disabled="form.processing"
106+
>
107+
Update
108+
</BreezeButton>
109+
</div>
110+
</form>
111+
</div>
112+
</div>
113+
</div>
114+
</div>
115+
</div>
116+
</div>
117+
</BreezeAuthenticatedLayout>
118+
</template>

resources/js/Pages/Admin/Permission/Index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function destroy(id) {
7777
<tr v-for="permission in permissions.data" :key="permission.id">
7878
<td class="border-b border-slate-100 dark:border-slate-700 p-4 pl-8 text-slate-500 dark:text-slate-400">
7979
<div class="text-sm text-gray-900">
80-
<a :href="route('permission.show', permission.id)" class="no-underline hover:underline text-cyan-600 dark:text-cyan-400">{{ permission.name }}</a>
80+
<Link :href="route('permission.show', permission.id)" class="no-underline hover:underline text-cyan-600 dark:text-cyan-400">{{ permission.name }}</Link>
8181
</div>
8282
</td>
8383
<td class="border-b border-slate-100 dark:border-slate-700 p-4 pl-8 text-slate-500 dark:text-slate-400">
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<script setup>
2+
import BreezeAuthenticatedLayout from "@/Layouts/Authenticated.vue";
3+
import { Head, Link, useForm } from "@inertiajs/inertia-vue3";
4+
import BreezeButton from "@/Components/Button.vue";
5+
6+
const props = defineProps({
7+
permission: {
8+
type: Object,
9+
default: () => ({}),
10+
},
11+
});
12+
</script>
13+
14+
<template>
15+
<Head title="View permission" />
16+
17+
<BreezeAuthenticatedLayout>
18+
<template #header>
19+
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
20+
Permissions
21+
</h2>
22+
</template>
23+
24+
<div class="py-12">
25+
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
26+
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
27+
<div class="p-6 bg-white border-b border-gray-200">
28+
<div class="flex flex-col">
29+
<div>
30+
<h1
31+
class="
32+
inline-block
33+
text-2xl
34+
sm:text-3xl
35+
font-extrabold
36+
text-slate-900
37+
tracking-tight
38+
dark:text-slate-200
39+
py-4
40+
block
41+
sm:inline-block
42+
flex
43+
"
44+
>
45+
View permission
46+
</h1>
47+
<Link
48+
:href="route('permission.index')"
49+
class="
50+
no-underline
51+
hover:underline
52+
text-cyan-600
53+
dark:text-cyan-400
54+
"
55+
>&lt;&lt; Back to all permissions</Link
56+
>
57+
</div>
58+
<div class="w-full py-2">
59+
<div class="min-w-full border-b border-gray-200 shadow">
60+
<table class="table-fixed w-full text-sm">
61+
<tbody class="bg-white dark:bg-slate-800">
62+
<tr>
63+
<td
64+
class="
65+
border-b border-slate-100
66+
dark:border-slate-700
67+
p-4
68+
pl-8
69+
text-slate-500
70+
dark:text-slate-400
71+
"
72+
>
73+
Name
74+
</td>
75+
<td
76+
class="
77+
border-b border-slate-100
78+
dark:border-slate-700
79+
p-4
80+
text-slate-500
81+
dark:text-slate-400
82+
"
83+
>
84+
{{ permission.name }}
85+
</td>
86+
</tr>
87+
<tr>
88+
<td
89+
class="
90+
border-b border-slate-100
91+
dark:border-slate-700
92+
p-4
93+
pl-8
94+
text-slate-500
95+
dark:text-slate-400
96+
"
97+
>
98+
Created
99+
</td>
100+
<td
101+
class="
102+
border-b border-slate-100
103+
dark:border-slate-700
104+
p-4
105+
text-slate-500
106+
dark:text-slate-400
107+
"
108+
>
109+
{{ new Date(permission.created_at).toLocaleString() }}
110+
</td>
111+
</tr>
112+
</tbody>
113+
</table>
114+
</div>
115+
</div>
116+
</div>
117+
</div>
118+
</div>
119+
</div>
120+
</div>
121+
</BreezeAuthenticatedLayout>
122+
</template>

0 commit comments

Comments
 (0)