dimanche 23 juillet 2017

Trying to get the relation using laravel eloquent but get null

I have two table with the following fields

adviser_group
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` INT(10) UNSIGNED NOT NULL,
`organization_id` INT(10) UNSIGNED NOT NULL,

organizations
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`status` TINYINT(4) NOT NULL DEFAULT '0',

adviser_group has 1 row, organization has many row

Using laravel uloquent i'm trying this,

  $organization = OrganizationAdviserGroup::with('organization')
    ->where('user_id', '=', Auth::user()->id)
    ->get();

But what I get, is the organization = null

Am i doing it wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire