I have the following method in my user
class:
/**
* Get all organisations for user (if owner)
*
* @param
*/
public function getOrganisationsOwned()
{
// If the user is owner of any one or many organisations then return this list
return Organisation::join('users', 'organisations.owner_id', '=', 'users.id')
->leftJoin('subscription_plans', 'organisations.subscription_plan_id', '=', 'subscription_plans.id')
->where('users.id', '=', $this->id)
->select('organisations.*', 'subscription_plans.*')
->get();
}
The method essentially queries and joins two tables. Each table has a column called title
.
The output from the above generates the rows as desired with the right info, but returns only one title
column, from the right table (subscription_plans
) but not the column title
from the left table (organisations
).
I understood that
->select('organisations.*', 'subscription_plans.*')
would make the query return both columns. What am I missing? Happy new year!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire