File tree 5 files changed +99
-11
lines changed
5 files changed +99
-11
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace App \Http \Controllers ;
4
4
5
+ use App \Http \Requests \RoleStoreRequest ;
5
6
use App \Http \Resources \RoleResource ;
6
7
use App \Models \Role ;
7
8
use Illuminate \Http \Request ;
@@ -30,9 +31,12 @@ public function create()
30
31
/**
31
32
* Store a newly created resource in storage.
32
33
*/
33
- public function store (Request $ request )
34
+ public function store (RoleStoreRequest $ request )
34
35
{
35
- //
36
+ $ validatedData = $ request ->validated ();
37
+ Role::create ($ validatedData );
38
+
39
+ return redirect ()->route ('roles.index ' )->with ('success ' , 'Role has been created! ' );
36
40
}
37
41
38
42
/**
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Http \Requests ;
4
+
5
+ use Illuminate \Foundation \Http \FormRequest ;
6
+
7
+ class RoleStoreRequest extends FormRequest
8
+ {
9
+ /**
10
+ * Determine if the user is authorized to make this request.
11
+ */
12
+ public function authorize (): bool
13
+ {
14
+ return true ;
15
+ }
16
+
17
+ /**
18
+ * Get the validation rules that apply to the request.
19
+ *
20
+ * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
21
+ */
22
+ public function rules (): array
23
+ {
24
+ return [
25
+ 'name ' => 'required|max:255 ' ,
26
+ ];
27
+ }
28
+ }
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public function up(): void
17
17
$ table ->string ('name ' , 255 );
18
18
$ table ->string ('email ' , 255 )->unique ();
19
19
$ table ->text ('description ' )->default ('Some description ' );
20
- $ table ->string ('avatar ' , 50 )->default ('placeholder ' );
20
+ $ table ->string ('avatar ' , 255 )->default ('placeholder ' );
21
21
$ table ->string ('password ' , 255 );
22
22
$ table ->rememberToken ();
23
23
$ table ->foreignId ('current_team_id ' )->nullable ();
Original file line number Diff line number Diff line change 1
1
<template >
2
- <div >
3
- create component
4
- </div >
5
- </template >
2
+ <AppLayout title =" Create role" >
3
+ <template #header >
4
+ <h2 class =" text-xl font-semibold leading-tight text-gray-800" >
5
+ Create role
6
+ </h2 >
7
+ </template >
8
+
9
+ <div class =" py-12" >
10
+ <div class =" mx-auto max-w-7xl sm:px-6 lg:px-8" >
11
+ <div class =" w-full max-w-xs m-auto" >
12
+ <form @submit.prevent =" submit" class =" px-8 pt-6 pb-8 m-auto mb-4 bg-white rounded shadow-md"
13
+ enctype =" multipart/form-data" >
14
+ <div class =" mb-4" >
15
+ <label class =" block mb-2 text-sm font-bold text-gray-700" for =" name" >
16
+ Role name <span class =" text-red-500" >*</span >
17
+ </label >
18
+ <input v-model =" form.name"
19
+ class =" w-full px-3 py-2 mb-2 leading-tight text-gray-700 border rounded shadow appearance-none focus:outline-none focus:shadow-outline"
20
+ id =" name" type =" text" />
21
+ <span class =" text-red-500" >{{ errors.name }}</span >
22
+ </div >
23
+
24
+ <div class =" flex items-center justify-between" >
25
+ <Button :form =" form" ></Button >
26
+ </div >
27
+ </form >
6
28
29
+ <p class =" text-xs text-center text-gray-500" >
30
+ © ; 2023 -
31
+ <a class =" text-blue-500" href =" https://github.com/perisicnikola37"
32
+ target =" _blank" >@perisicnikola37</a >
33
+ </p >
34
+ </div >
35
+ </div >
36
+ </div >
37
+ </AppLayout >
38
+ </template >
39
+
7
40
<script >
8
- export default {
41
+ import Button from ' @/Components/Button.vue' ;
42
+ import AppLayout from ' @/Layouts/AppLayout.vue' ;
9
43
10
- }
11
- </script >
44
+ export default {
45
+ components: {
46
+ AppLayout,
47
+ Button
48
+ },
49
+ props: {
50
+ errors: Object
51
+ },
52
+ data () {
53
+ return {
54
+ form: this .$inertia .form ({
55
+ name: ' ' ,
56
+ })
57
+ };
58
+ },
59
+ methods: {
60
+ submit () {
61
+ this .form .post (this .route (' roles.store' ), {
62
+ });
63
+ }
64
+ }
65
+ };
66
+ </script >
67
+
Original file line number Diff line number Diff line change 88
88
</template >
89
89
90
90
<script >
91
- import AppLayout from ' @/Layouts/AppLayout.vue' ;
92
91
import Button from ' @/Components/Button.vue' ;
92
+ import AppLayout from ' @/Layouts/AppLayout.vue' ;
93
93
94
94
export default {
95
95
components: {
You can’t perform that action at this time.
0 commit comments