in My Larvel 5.6 app I am working with mysql db. and in my application I have vehicle table with following columns, vehicles,
id category number brand model
1 car 123 bmw 520d
2 van 258 ford mark
3 car 256 benz ultra
4 car 259 bmw 520d
etc
and I am going to group all models of the table and printing here as My controller,
public function modelstatic()
{
$models = Vehicle::groupBy('modelname')->select('id', 'modelname', \DB::raw('COUNT(*) as cnt'))->get();
return view('modelreports.modelstatic')->withModels($models);
}
my printing blade file is this,
@foreach($models as $model)
@endforeach
it is printing well as
520d
mark
ultra
now I need print in-front of model name there brand name as
520d - bmw
mark - ford
ultra - benz
then how can I do this now? I have separate Models for brand and model and still there are not relationship between Modols. how can I do this, may I need relationship or may I could print brand name via vehicle table data?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire