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()
3333
3434 public function store (UserValidate $ request )
3535 {
36- $ user = User::create ($ request ->validated ());
36+ User::create ($ request ->validated ());
3737
3838 return redirect ()->route ('user.index ' )
3939 ->with ('success ' , 'User created ' );
Original file line number Diff line number Diff line change @@ -18,9 +18,8 @@ public function rules()
1818 'name ' => 'required ' ,
1919 'email ' => 'required|email ' ,
2020 'password ' => $ this ->passwordRules (),
21- // 'profile_type' => '',
22- // 'profile_id' => ''
23-
21+ 'profile_type ' => 'string ' ,
22+ 'profile_id ' => 'integer|numeric ' ,
2423 ];
2524 }
2625
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ protected static function newFactory()
3232 'name ' ,
3333 'email ' ,
3434 'password ' ,
35+ 'profile_type ' ,
36+ 'profile_id ' ,
3537 ];
3638
3739 /**
@@ -62,4 +64,9 @@ public function sendPasswordResetNotification($token)
6264 {
6365 $ this ->notify (new ResetPassword ($ token ));
6466 }
67+
68+ public function profile ()
69+ {
70+ return $ this ->morphTo ();
71+ }
6572}
Original file line number Diff line number Diff line change 4848</template >
4949
5050<script setup>
51+ import { onMounted } from ' vue'
5152import { useForm } from ' @inertiajs/vue3'
5253
5354import useTitle from ' @/Composables/useTitle'
@@ -61,6 +62,20 @@ const props = defineProps({
6162 }
6263})
6364
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+
6479const breadCrumb = [
6580 { label: ' Home' , href: route (' dashboard.index' ) },
6681 { label: ' Users' , href: route (' user.index' ) },
You can’t perform that action at this time.
0 commit comments