Support the ongoing development of Laravel.io →
Input Database Eloquent

I am attempting to save a related model (Access.php) from my AuthenticationController on login

AuthenticationController uses User model, relationship is User hasMany Access records so wondering what is the best way to do so?

I am used to other frameworks where I would chain the models like $this->User->Access->saveUserAccess($auth_id);

I can bypass and simply use DB::table('access')->insert([myData => xxx]); But is there a correct way? Best way?

Since we take the time to define the relationships it seems it would be best to use them accordingly.

How can I use the chaining method or similar in Laravel.

Thanks,

Dave

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.