Support the ongoing development of Laravel.io →
Input Database
Last updated 2 years ago.
0

Try print_r($input) after Institution::create($input);

If you are going to add only admin_id on institution table, why do you pass whole $input.

Last updated 2 years ago.
0

Can you show us your models?

I'm assuming this is because admin_id isn't mass assignable, which being an ID you don't really want, so you can do it this way to get around the mass assignment problem.

$institution = new Institution;

$institution->fill(Input::all());

$user->institution()->save($institution); // Automagically associated the $institution with $user using Laravels relationships

or alternativly

$institution = new Institution;

$institution->fill(Input::all());
$institution->admin_id = $user->id;

$institution->save();
Last updated 2 years ago.
0

iWader said:

Can you show us your models?

I'm assuming this is because admin_id isn't mass assignable, which being an ID you don't really want, so you can do it this way to get around the mass assignment problem.

$institution = new Institution;

$institution->fill(Input::all());

$user->institution()->save($institution); // Automagically associated the $institution with $user using Laravels relationships

or alternativly

$institution = new Institution;

$institution->fill(Input::all());
$institution->admin_id = $user->id;

$institution->save();

That perfect! Thank you

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

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.

© 2024 Laravel.io - All rights reserved.