mercredi 29 juin 2016

Laravel 5.1 Creating default object from empty value

I am using Laravel 5.1 PHP framework.When I try to update my record,i get the error "ErrorException in AdminController.php line 108: Creating default object from empty value".I have searched in google but i can't find any result to solve my problem.

routes

Route::get('/admin/no', 'AdminController@index');
Route::get('/admin/product/destroy/{id}', 'AdminController@destroy');
Route::get('/admin/new', 'AdminController@newProduct');
Route::post('/admin/product/save', 'AdminController@add');
Route::get('/admin/{id}/edit', 'AdminController@edit');
Route::patch('/admin/product/update/{id}', 'AdminController@update')

AdminController

 public function edit($id)
    {

        $product = Product::find($id);
        return view('admin.edit', compact('product'));

    }

    public function update(Request $request, $id)
    {

        $product = Product::find($id);
        $product->id = Request::input('id');
        $product->name = Request::input('name');
        $product->description = Request::input('description');
        $product->price = Request::input('price');
        $product->imageurl = Request::input('imageurl');


        $product->save();
        //return redirect('/admin/nο');

    }
    enter code here

edit.blade.php

div class="panel panel-info">
        <div class="panel-heading">
            <div class="panel-title">Edit Product</div>
        </div>
        <div class="panel-body" >
            <form action="/admin/product/update/{id}" method="POST"><input type="hidden" name="_method" value="PATCH"> <input type="hidden" name="_token" value="">
    enter code here



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/29cApAG
via IFTTT

Aucun commentaire:

Enregistrer un commentaire