2

I am having a problem on insert into DB with information coming from a blade form. The system is not sending to the DB and it doesn't actually through any sense error. It all seems ok and i cant find a possible mistake. Any clue on what might be happening?

This is my blade:

                            {!! Form::open(['method'=>'post', 'action'=>'AdminTasksController@store']) !!}

                                <div class="form-group' has-error' : '' }}">
                                    <div class="col-md-6">
                                        {!! Form::select('category_id',[''=>'Chose categories'] + $categories,null,['class'=>'form-control']) !!}
                                    </div>
                                </div>

                                <div class="form-group' has-error' : '' }}">
                                    <div class="col-md-6">
                                        {!! Form::select('job_id',[''=>'Chose job type'] + $jobs,null,['class'=>'form-control']) !!}
                                    </div>
                                </div>

                                <input type="hidden" name="house_id" value="{{Auth::user()->house->id}}">

                                <div class="form-group">
                                    <div class="col-md-6">
                                        {!! Form::select('user_id',[''=>'Chose user'] + $users->toArray(),null,['class'=>'form-control']) !!}
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-6">
                                        {!! Form::number('task_priority', null, ['placeholder'=>'Task Priority', 'min'=>1, 'max'=>10]) !!}
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-6">
                                        {!! Form::date('task_expire', null, ['placeholder'=>'Expire date']) !!}
                                    </div>
                                </div>

                                <br>

                                <div class="form-group">
                                    <div class="col-md-6 col-md-offset-4">
                                        <button type="submit" class="btn btn-primary">
                                            Register
                                        </button>
                                    </div>
                                </div>
                            {!! Form::close() !!}

This is my controller method on AdminTasksController:

public function store(Request $request){


        Task::create($request->all());

        return redirect('/admin/task');


    }

This is my router, the problem might be coming from here, but just in case:

//tasks
Route::get('/admin/task', 'AdminTasksController@index')->name('admin/task');
Route::get('/admin/task/create', 'AdminTasksController@create')->name('admin/task/create');
Route::get('/admin/task/store', 'AdminTasksController@store')->name('admin/task/store');

Route::get('/user/task', 'AdminTasksController@userIndex')->name('user/task');
1
  • Try changing action'=>'AdminTasksController@store' to action="/admin/task/store" and the Route from get to post Commented Feb 8, 2018 at 14:19

1 Answer 1

1

Change this route to Route::post:

Route::post('/admin/task/store', 'AdminTasksController@store')->name('admin/task/store');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.