I get the following error:
BadMethodCallException in Builder.php line 1999: Call to undefined method Illuminate\Database\Query\Builder::Client()
when using Laravel 5 eager loading with()
$products = Product::with(['Client'])->get();
A client can have many products. A product belongs to one client.
Product model:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Product extends Model {
/**
* Client who has this product.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function clients()
{
return $this->belongsTo('App\Client');
}
Client model:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Client extends Model {
/**
* Appointment that this client has.
*
* @return \Illuminate\Database\Eloquent\Relations\hasMany
*/
public function products()
{
return $this->hasMany('App\Product');
}
Am I missing a relationship? Thanks
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1hfgzVi
via IFTTT
Aucun commentaire:
Enregistrer un commentaire