T
T
The Dragger2016-09-20 14:30:30
Laravel
The Dragger, 2016-09-20 14:30:30

How to be removed Route::controller in Laravel 5.3?

Before version 5.3, I had this CRUD :

public function getIndex()
public function getForm($id = null)
    {
        if ($id) {
            $category = Category::find($id);
        } else {
            $category = [];
        }
        return view('backend.categories.form', compact('category'));
    }

    public function postForm(Request $request, $id = null)
    {
        $data = $request->except('_token');
        $data['alias'] = $this->aliasCreate($data['name']);
        if ($id) {
            $category = Category::find($id)->update($data);
        } else {
            $category = Category::create($data);
        }
        Session::flash('success', 'Success');
        return Redirect::action('Backend\[email protected]');
    }

    public function getDelete($id)
    {
// тут delete
    }

    private function aliasCreate($value)
    {
        // тут создаем alias
    }

getForm - I had both view and update and create. For me it is very convenient. But now in 5.3 Route::controller has been removed. An alternative to Route::resource , but there are a lot of unnecessary methods. How to be? jump to resource ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2016-09-20
@IPD2

controller was cut out to remove non-obviousness, i.e. magic controllers that do not know what.
Now you need to explicitly specify everything, or use resource (which, by the way, you haven’t even tried, since you don’t know that there are generally rigid frameworks, and you won’t use it especially in any way).
So now only:
Router::get('func', '\App\Http.....');
Router::post('func', '\App\Http.....');
etc.
every controller method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question