mardi 1 mars 2016

How to Set Url for Update Data in Laravel 5.2

My Friend my problem with URL $category in Laravel update post my view update post:

{{--insert category--}}
    <div class="col-sm-6">
        {{Form::model($category,['method'=>'patch','url'=>['category/update',$category->id]])}}
        <div class="form-group">
            <div class="form-group">
                {{form::text('category','',['class'=>'form-control text-right','placeholder'=>'submit'])}}
            </div>
            {{form::submit('submit',['class'=>'btn btn-primary'])}}
        </div>
        {{Form::close()}}
    </div>

my route :

Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('update/{id}', 'categoryController@update');
});
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::post('update/{id}', 'categoryController@patchUpdate');
});

my controller:

    public function update($id){
    Category::find($id);
    return view('admin.updateCategory',compact('id'));
}
public function patchUpdate($id,request $request){
    $category = Category::find($id);
    return redirect('category');
}

my error is:

Undefined variable: category (View: C:\wamp\www\pc\resources\views\admin\updateCategory.blade.php)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire