Skip to content

Commit 5201e61

Browse files
Finish updating a role functionality
1 parent 3d0b617 commit 5201e61

File tree

2 files changed

+56
-7
lines changed

2 files changed

+56
-7
lines changed

app/Http/Controllers/RoleController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public function edit(Role $role)
6060
*/
6161
public function update(Request $request, string $id)
6262
{
63-
//
63+
Role::where('id', $id)->update($request->all());
64+
65+
return redirect('/roles')->with('success', 'Role has been updated!');
6466
}
6567

6668
/**

resources/js/Pages/Roles/Edit.vue

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,65 @@
11
<template>
2-
<div>
3-
<AppLayout title="Edit role">
4-
Edit role: {{ role.name }}
5-
</AppLayout>
6-
</div>
2+
<AppLayout title="Edit role">
3+
4+
<template #header>
5+
<Breadcrumb :href="'roles'" :title="'Roles'" :property="role" />
6+
</template>
7+
8+
<div class="py-12">
9+
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
10+
<div class="w-full max-w-xs m-auto">
11+
<form @submit.prevent="submit" class="px-8 pt-6 pb-8 mb-4 bg-white rounded shadow-md">
12+
13+
<div class="mb-4">
14+
<label class="block mb-2 text-sm font-bold text-gray-700" for="name">
15+
Role name
16+
</label>
17+
<input v-model="form.name"
18+
class="w-full px-3 py-2 leading-tight text-gray-700 border rounded shadow appearance-none focus:outline-none focus:shadow-outline"
19+
id="name" type="text">
20+
</div>
21+
22+
<div class="flex items-center justify-between">
23+
<Button :form="form"></Button>
24+
</div>
25+
</form>
26+
<p class="text-xs text-center text-gray-500">
27+
&copy;2023 - <a class="text-blue-500" href="https://github.com/perisicnikola37"
28+
target="_blank">@perisicnikola37</a>
29+
</p>
30+
</div>
31+
32+
</div>
33+
</div>
34+
</AppLayout>
735
</template>
836

937
<script>
38+
import Breadcrumb from "@/Components/Breadcrumb.vue";
39+
import Button from "@/Components/Button.vue";
1040
import AppLayout from '@/Layouts/AppLayout.vue';
1141
1242
export default {
43+
components: {
44+
AppLayout,
45+
Breadcrumb,
46+
Button
47+
},
1348
props: {
1449
role: Object,
1550
},
16-
components: { AppLayout }
51+
data() {
52+
return {
53+
form: this.$inertia.form({
54+
name: this.role.name,
55+
})
56+
}
57+
},
58+
methods: {
59+
submit() {
60+
this.form.put(this.route('roles.update', this.role.id), {
61+
})
62+
}
63+
}
1764
}
1865
</script>

0 commit comments

Comments
 (0)