Open soufianoxx opened 1 year ago
i have tables Hotel,Hotelchamber,Chambertime class hotel:
`
Class Hotel extends Model{ public function chambers() { return $this->hasMany(Hotelchamber::class,'hotel_id'); } }
and class Hotelchamber:
`class Hotelchamber extends Model { public function chamber() { return $this->belongsTo(Hotel::class,'hotel_id'); } public function times() { return $this->hasMany(Chambertime::class); } }`
`class Hotelchamber extends Model {
public function chamber() { return $this->belongsTo(Hotel::class,'hotel_id'); } public function times() { return $this->hasMany(Chambertime::class); }
}`
and class Chambertime:
class Chambertime extends Model { public function chamber() { return $this->belongsTo(Hotelchamber::class,'hotelchamber_id'); } }
i want add now hotel with chamber and time, and i use : `
$form->hasMany('chambers', function (Form\NestedForm $subform) { $subform->text('name', ('Type'))->required(); $subform->number('adult', ('Nombre d\'adultes'))->required(); $subform->number('enfant', ('Nombre d\'enfants'))->required(); $subform->hasMany('times', function (Form\NestedForm $sform) { $sform->date('datefrom', ('Du'))->required(); $sform->date('dateto', ('Au'))->required(); $sform->currency('prix', ('Prix'))->symbol('dhs')->required(); }); });
but i have this error: `
Call to undefined method App\Hotel::times()
`how i can add time for each chamber of hotel
Description:
i have tables Hotel,Hotelchamber,Chambertime class hotel:
`
`
and class Hotelchamber:
and class Chambertime:
i want add now hotel with chamber and time, and i use : `
`
but i have this error: `
`how i can add time for each chamber of hotel