lundi 21 novembre 2016

Laravel sync hasMany and belongsTo in reverse?

Is there a simple way to do a "sync" (as per a many-to-many) relationship in one line between a hasMany and a belongsTo relationship?

i.e. something like this

$opportunity->quotations()->sync($request->input('quotation_list', [])); 

Below is how the model is configured.

public function quotations()
{
    return $this->hasMany('App\Quotation');
}

public function opportunity()
{
    return $this->belongsTo('App\Opportunity');
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire