I am working with laravel 5.6. and in my application I have table name vehicles as like this,
id name model year categoryname user_id
1 toyota 121 2001 car 1
2 nissan sunney 1998 car 2
3 toyota liteace 2000 van 5
4 isuzu elf 2005 truck 9
5 bmw 520d 2010 car 7
now I need redirect each vechicle edit form acording to categoeyname of the vechicle table. I have controller edit function like this?
public function edit($id)
{
if (Vehicle::where('categoryname', 'Car')) {
$vehicles = Vehicle::find($id);
$town_list = Town::with('district.province')->groupBy('provincename')->get();
$model_list = DB::table('modols')
->groupBy('categoryname')
->get();
return view('vehicles.caredit')->withVehicles($vehicles)->withTown_list($town_list)->withModel_list($model_list);
}
else if (Vehicle::where('categoryname', 'Van')){
$vehicles = Vehicle::find($id);
$town_list = Town::with('district.province')->groupBy('provincename')->get();
$model_list = DB::table('modols')
->groupBy('categoryname')
->get();
returnview('vehicles.vanedit')->withVehicles($vehicles)->withTown_list($town_list)->withModel_list($model_list);
}
}
but when I redirect diffrent categoryname values like car and van those are allways redirect to caredit.blade.php. then how can I fix this problem?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire