jeudi 20 août 2015

Using Form button/Eloquent to set an entire column to null

I am having a real issue getting a button to scan and clear out an entire column using an eloquent model. I have two columns in my SQLite DB, "States" and "Totals"... I want the States to stay in their own order, but I want the totals to be cleared out upon the user selecting a button. The character type for 'totals' is BigInt... After the user selects the button, I want them redirected to the home page (with the values cleared so they can start over).

Here are my routes:

Route::resource('states', 'StateController');
Route::get('/', 'StateController@index');
Route::post('create', 'StateController@store');
Route::post('states.update', 'StateController@update');

Here is my controller:

public function update()
{
    Distributors::update(['total' => null]);
    return View::make('states');
}

Here is my form:

{{ Form::open(['route' => 'states.update']) }}

{{ Form::submit('Destroy and Start Anew') }}

{{ Form::close() }}

The error I get is:

MethodNotAllowedHttpException

Is this all because I am using RESTful routing?? Is there a simple issue with my routes? I can't figure it out.

Aucun commentaire:

Enregistrer un commentaire