File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed
stubs/resources/js/Pages/User Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function create()
33
33
34
34
public function store (UserValidate $ request )
35
35
{
36
- $ user = User::create ($ request ->validated ());
36
+ User::create ($ request ->validated ());
37
37
38
38
return redirect ()->route ('user.index ' )
39
39
->with ('success ' , 'User created ' );
Original file line number Diff line number Diff line change @@ -18,9 +18,8 @@ public function rules()
18
18
'name ' => 'required ' ,
19
19
'email ' => 'required|email ' ,
20
20
'password ' => $ this ->passwordRules (),
21
- // 'profile_type' => '',
22
- // 'profile_id' => ''
23
-
21
+ 'profile_type ' => 'string ' ,
22
+ 'profile_id ' => 'integer|numeric ' ,
24
23
];
25
24
}
26
25
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ protected static function newFactory()
32
32
'name ' ,
33
33
'email ' ,
34
34
'password ' ,
35
+ 'profile_type ' ,
36
+ 'profile_id ' ,
35
37
];
36
38
37
39
/**
@@ -62,4 +64,9 @@ public function sendPasswordResetNotification($token)
62
64
{
63
65
$ this ->notify (new ResetPassword ($ token ));
64
66
}
67
+
68
+ public function profile ()
69
+ {
70
+ return $ this ->morphTo ();
71
+ }
65
72
}
Original file line number Diff line number Diff line change 48
48
</template >
49
49
50
50
<script setup>
51
+ import { onMounted } from ' vue'
51
52
import { useForm } from ' @inertiajs/vue3'
52
53
53
54
import useTitle from ' @/Composables/useTitle'
@@ -61,6 +62,20 @@ const props = defineProps({
61
62
}
62
63
})
63
64
65
+ onMounted (() => {
66
+ if (
67
+ isCreate .value &&
68
+ route ().params .profile_type &&
69
+ route ().params .profile_id
70
+ ) {
71
+ form .transform ((data ) => ({
72
+ ... data,
73
+ profile_type: route ().params .profile_type ,
74
+ profile_id: route ().params .profile_id
75
+ }))
76
+ }
77
+ })
78
+
64
79
const breadCrumb = [
65
80
{ label: ' Home' , href: route (' dashboard.index' ) },
66
81
{ label: ' Users' , href: route (' user.index' ) },
You can’t perform that action at this time.
0 commit comments