How to Insert Relationship Via Controller

Solved Posted In Laravel
  • keshan-sandeepa 1 year ago
    Hello , I have 2 models , one is user other one is register , 
    "User hasone register " i need to create that relationship , Problem is even i created data is not saving in database, 
    here is the screen shots  in my code : 
    
    1. Register Model   ![https://imgur.com/a/xdEZthE](https://imgur.com/a/xdEZthE)
    2. User Model  ![https://imgur.com/a/EMY8n76](https://imgur.com/a/EMY8n76)
    
    
    Here is my controller Screenshot
    1. ![https://imgur.com/a/UuFLLJA](https://imgur.com/a/UuFLLJA)
    
    Problem is itsnot saving when  user fill my form , How to fixed that . help me =D 

    Hello , I have 2 models , one is user other one is register , "User hasone register " i need to create that relationship , Problem is even i created data is not saving in database, here is the screen shots in my code :

    1. Register Model https://imgur.com/a/xdEZthE
    2. User Model https://imgur.com/a/EMY8n76

    Here is my controller Screenshot

    1. https://imgur.com/a/UuFLLJA

    Problem is itsnot saving when user fill my form , How to fixed that . help me =D

  • Best Answer

    (As selected by keshan-sandeepa)

    mark 1 year ago
    Add `$customer->save();` after `$customer->id = $request->user_id;`.
    
    ----------
    Best Regards,    
    Mark Topper (Maintainer of [Laravel Voyager](https://laravelvoyager.com))    
    Mail: [[email protected]](mailto:[email protected])    
    *I am available for freelance work - [hire me](mailto:[email protected])*
    

    Add $customer->save(); after $customer->id = $request->user_id;.


    Best Regards,
    Mark Topper (Maintainer of Laravel Voyager)
    Mail: [email protected]
    I am available for freelance work - hire me

  • mark 1 year ago
    Add `$customer->save();` after `$customer->id = $request->user_id;`.
    
    ----------
    Best Regards,    
    Mark Topper (Maintainer of [Laravel Voyager](https://laravelvoyager.com))    
    Mail: [[email protected]](mailto:[email protected])    
    *I am available for freelance work - [hire me](mailto:[email protected])*
    

    Add $customer->save(); after $customer->id = $request->user_id;.


    Best Regards,
    Mark Topper (Maintainer of Laravel Voyager)
    Mail: [email protected]
    I am available for freelance work - hire me

Please login or signup to leave a response.

Login

or Sign Up

Sign Up

or Login
×
Want to create your own SAAS?

I can teach you to create your own Software as a Service. Click here to learn more!

Visit SAAS Adventure!