dimanche 23 octobre 2016

Laravel 5 variable not being recognised

Bit of an odd problem which is probably because I am finding my feet with Laravel.

I have an edit page which is accessed by:

Route::get('editRow/{id}', function($id){
    $section = App\Section::where('id', $id)->with('panels')->first();
    return view('front.editrow',['thesection'=>$section]);
});

This form then is completed and goes to a controller with a longish method to update the table and ends with:

return view('front.editrow',['message'=>'update successful','id'=>$request->id]);

The DB is updated OK. Initially I was getting an error so I copied the route and changed it from a get to a post:

Route::post('editRow/{id}', function($id){
    $section = App\Section::where('id', $id)->with('panels')->first();
    return view('front.editrow',['thesection'=>$section]);
});

Now although this is exactly the same parameters etc I always get;

Undefined variable: thesection

I am baffled and would greatly appreciate this mystery being solved!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire