У меня есть модель CalendarEvent, которая имеет отношение morphTo (полиморфное) к нескольким моделям, одна из которых StaffRoster.
Когда вызывается отношение, laravel, кажется, «зависает», когда веб-страница загружается вечно,и если это действительно загружает, пустая, белая страница подана.
код выглядит следующим образом:
Миграции:
Schema::create('calendar_event', function (Blueprint $table) {
$table->bigIncrements('id');
$table->morphs("model");
$table->text("google_calendar_id");
$table->date("event_date");
$table->timestamps();
});
Schema::create('staff_roster', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger("users_id");
$table->date("date");
$table->time("start_time");
$table->time("end_time");
$table->timestamps();
});
Модели:
class StaffRoster extends Model
{
protected $table = "staff_roster";
protected $guarded = [];
protected $with = [
"calendar_event"
];
public function calendar_event(){
return $this->morphOne("App\CalendarEvent", "model");
}
}
class CalendarEvent extends Model
{
protected $table = "calendar_event";
protected $with = [
"model",
];
protected $fillable = [
"model_type",
"model_id",
"event_date",
"google_calendar_id",
];
public function model(){
return $this->morphTo();
}
}
клей:
dd(CalendarEvent::find(1)); // Hangs
Любая помощь с этим будет принята с благодарностью!