I have a station model which is related to journal batches like
in station model
class Station extends Model{
public function whsemast()
{
return $this->belongsTo(WhseMst::class,'warehouse_to_transfer','WhseLink');
}
}
Now in my controller i would like to get the name of warehouse(whsemst) in a station
So i have
$data = Station::with('whsemast')->select(['id', 'location','whsemast.name'])->get();
But the above throws an erro
identifier "whsemast.name" could not be bound
I have also tried adding
$records = Station::select(['id', 'location'])
->with(['whsemast' => function($query) {
$query->select('name');
}])->get();
But in this case am getting whsemas as null
When i check
Station::with('whsemast')->get() //whsemast has data here
where am i wrong as i would expect it to return some data using the select
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire