you should look into Relationships if you want to learn Laravel http://laravel.com/docs/eloquent#relationships
if you set it up correctly you can use stuff like
$user = User::with('characters', 'clan')->where('username', '=', 'Zenry')->first();
$user->characters; // all characters belonging to the user
$user->clan; // dito
zenry said:
you should look into Relationships if you want to learn Laravel http://laravel.com/docs/eloquent#relationships
if you set it up correctly you can use stuff like
$user = User::with('characters', 'clan')->where('username', '=', 'Zenry')->first();
$user->characters; // all characters belonging to the user $user->clan; // dito
The problem is, the user doesnt always have a clan, and if none found laravel would throw an error. A character is created upon registration of the account. But a clan is not. The code above will search for a clan that is connected to the user. Therefor I will need a query with a WhereExists function in it if I am correct? Or will the code above NOT show an error once there is no clan connected to the user?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community