I am using legacy tables and have a model for PartDetail:
class PartDetail extends Model
{
protected $table = 'partdetails';
protected $primaryKey = 'ID';
public $timestamps = false;
protected $connection = 'common';
public function Manufacturer()
{
return $this->hasOne('\App\Manufacturer','entry','Manufacturer');
}
}
My Manufacturers model is
class Manufacturer extends Model
{
protected $table = 'manufacturer';
protected $primaryKey = 'entry';
public $timestamps = false;
protected $connection = 'common';
public function Parts()
{
return $this->hasMany('\App\PartDetail','Manufacturer','entry');
}
}
and so I have a route:
Route::get('/partdetails', function(){
$parts = App\PartDetail::with('Manufacturer')->orderBy('PartNo')->limit(20)->get();
return view ('stock.parts', ['parts'=>$parts]);
});
If I dd($parts) all is correct but if I try to list the manufacturer is ignored:
<?php //dd($parts); ?>
@foreach($parts as $items)
, , <br/>
@endforeach
Any ideas what I am during wrong please?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jbhBTM
via IFTTT
Aucun commentaire:
Enregistrer un commentaire