using Laravel 5.6 and MySQL in My application. In My system I have saving some information about vehicles types like car, van, bus, truck... some of all vehicles type have common values and those are saving in vehicle table, like this
id name model year category_name 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
and some specific information for each vehicle type saving separate tables like cars, vans, trucks etc each table related with vehicle table with vechicle_id
car table like this
id fuel transmission vehicle_id
1 p auto 1
2 d mannual 7
3 e auto 6
4 p auto 5
5 p auto 3
and each user can access they created ads in there account and its VehicleController is like this,
public function indexpersonel()
{
$vehicles = Vehicle::personal()->get();
return view('vehicles.myads')->withVehicles($vehicles);
}
and Vehicle Model
public function scopePersonal($query)
{
return $query->where('user_id', Auth::user()->id);
}
and each ads showing blade file is,
<td><a class="button is-outlined" href="" >Edit</a></td>
<td><a class="button is-outlined" href="/myads//delete" onclick="return confirm('Are you sure to want to delete this record?')" >Delete</a></td>
</a>
ok now my problem is there currently I have vehicle information edit file as edit.blade.php in vehicles view file. but as a result of some specific values of each vehicles type unable to use above common edit form. so, I need seperete edit forms for each vehicle types like caredit, vanedit etc... so, How can create and route with users accounts created ads as above. now I need urls when going to some vehicle edit like this,
http://localhost:8000/myads/car/18/edit,
http://localhost:8000/myads/van/20/edit
My current route for vehicle edit is,
Route::get('myads/{id}/edit', [
'uses' => '\App\Http\Controllers\VehicleController@edit',
'as'=> 'vehicles.edit'
]);
how can do this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire