Jan 21, 2015
0
Level 1
Update a relationship with eloquent
Hi.
I have 3 tables: boote (boats): id,name,... sportler (athletes):id,name,... boot_sportler : id,boot_id,sportler_id,position,...
In the Table boot_sportler is the relationship. On boat can have many athlets. I want to update a boat and want that the athlets will saved automaticly.
I have 3 classses:
class Sportler extends Eloquent {
protected $table = 'sportler';
public function bootsbesatzungen(){
return $this->belongsToMany('Bootsbesatzungen');
}
}
class Boote extends Eloquent {
protected $table = 'boote';
public function bootsbesatzung(){
return $this->hasMany('Bootsbesatzungen','boot_id');
}
}
class Bootsbesatzungen extends Eloquent {
protected $table = 'boot_sportler';
public function sportler(){
return $this->belongsTo('Sportler','sportler_id');
}
}
And i have a blade file with textboxes to enter athlete names, boat name,... how i should integrate the data in my form? And how is the method to update it? in the moment i do it manually, but i want this with eloquent.
Thanks
Please or to participate in this conversation.