Стремительная загрузка не тянет модель отношений.
Привет, я использую Laravel 6. Наша база данных была создана с Zend, поэтому наша модель немного странная; Я должен установить первичные ключи.
// Customer model
protected $table = 'customer';
protected $primaryKey = 'Customer_ID';
/**
* Get all appointments for the customer.
*/
public function appointments()
{
return $this->hasMany('App\Appointment');
}
Затем для встреч
protected $table = 'appointment';
protected $primaryKey = 'Appointment_ID';
/**
* Get the customer assigned to this appointment.
*/
public function customer()
{
return $this->belongsTo('App\Customer');
}
Теперь в контроллере:
$appointments = App\Appointment::with('customer')->take(5)->get();
return response()->json($appointments, 200);
Массив имеет назначения но клиент нулевой:
{... Customer_ID: 1234, customer: null}
Есть идеи? Спасибо