I have the following model for Users:
class User extends Authenticatable
{
use Notifiable;
protected $table = 'login_info';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function getDashboards()
{
return \DB::table('dashboard')
->select('type')
->where('id', Auth::id())
->orderBy('column', 'asc')
->get();
}
}
Users have different information in many tables (user info like name, office, dashboard,2FA etc). Is the way I do it now "best practice" (like the getDashboards function) for getting information from different tables? Or should I create a model for each of the tables and then "join them" (hasMany, belongsToMany, and so on) for each of the tables?
Thanks for any help!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire