class Guest extends Model{
public function programs()
{
return $this->belongsToMany(Program::class, 'guest_show', 'guest_id', 'program_id')
->withPivot('subject', 'show_date');
}
public function specialties()
{
return $this->belongsToMany(Specialization::class,'guest_speciality','guest_id','speciality_id');
}
class Program extends Model{
protected $table = 'programs';
protected $primaryKey = 'program_id';
public function guests()
{
return $this->belongsToMany(Guest::class,'guest_show','program_id','guest_id')
->withPivot('subject', 'show_date');
}}
class Specialization extends Model{
protected $table = 'specialties';
protected $primaryKey = 'specialty_id';
public function guests()
{
return $this->belongsToMany(Guest::class,'guest_speciality','speciality_id','guest_id');
}
我有表格:guests,programs,specialties,guest_speciality,guest_show
我有所有表中的表单,该表单包含程序表中的选择选项和特殊表中的选择选项。
控制器功能和视图如何编写此模型的代码?