jeudi 5 mai 2016

Laravel 5.2 + How to save record in DB

While working with laravel 5.2 since last 2 weeks, I have found one new method to store records in DB.

For Instance

 User table 
 id      name
 1       Test 1
 2       Test 2

 Project Table
 id     user_id      name
 1      1            Project 1
 2      2            Project 2

User and Project table are linked in Foreign Key constraint.

To store in Project table, I have used below line of code.

Auth::user()->projects()->save($project);

Can I have similar kind of solution if I want to store record in Task table? Where project_id and user_id are foreign key constraints of project and user table respectively.

Task Table 
id    project_id     user_id      name
1     1              1            test task



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1NZacoy
via IFTTT

Aucun commentaire:

Enregistrer un commentaire