Imagine a User-model that is associated with one Phone-model as a one-to-one relationship as defined by Eloquent Relationships, meaning that the User-model has a function:
/**
* Get the phone record associated with the user.
*/
public function phone()
{
return $this->hasOne('App\Phone');
}
while the Phone-model has a function:
/**
* Get the user that owns the phone.
*/
public function user()
{
return $this->belongsTo('App\User');
}
The question is now how to make a CRUD controller in Backpack for Laravel, which makes is possible to add a new User where the Phone is also provided in the same CRUD add/edit form.
It seems to be standard that you add a Phone resource and then add a User resource where there is a select-field where you can choose an existing Phone resources, but instead I am trying to add a new User with a new Phone in one CRUD controller, and also editing a User while at the same time editing his Phone.
Here are two examples of how it could look: Illustration of Backpack Add-form for a User-model with a one-to-one relation to the Phone-model
I hope this makes sense.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2E7Z6uw
via IFTTT
Aucun commentaire:
Enregistrer un commentaire