Home » Php » mysql – PHP-LARAVEL 6 Created category returns 404

mysql – PHP-LARAVEL 6 Created category returns 404

Posted by: admin February 25, 2020 Leave a comment

Questions:

I need your help please.
When I create a new category at my laravel project it doesn’t show the products I inserted after, but returns “404 page not found” and 2 other categories I created in phpmyadmin at the start of the project (for tests) they are working good. I can’t find the problem why it returns 404 doesnt matter with or without products in it.
Thank you!!! Heres the code:

---------------------------------------------ROUTES:------------------------------------------
    #CMS
    Route::prefix('cms')->group(function () {
      Route::middleware(['cmsguard'])->group(function () {
        Route::get('dashboard', '[email protected]');
        Route::get('orders', '[email protected]');
        Route::resource('menu', 'MenuController');
        Route::resource('content', 'ContentController');
        Route::resource('categories', 'CategoriesController');
        Route::resource('products', 'ProductsController');
      });
        });

    --------------------------------------------CREATE CATEGORY:------------------------------
        $category = new self();
        $category->ctitle = $request['title'];
        $category->carticle = $request['article'];
        $category->curl = $request['url'];
        $category->cimage = $image_name;
        $category->save();
        Session::flash('sm', 'Category Is Saved!');

--------------------------------------UPDATE CATEGORY:----------------------------------------
    $category = self::find($id);
    $category->ctitle = $request['title'];
    $category->carticle = $request['article'];
    $category->curl = $request['url'];
    if ($image_name) {
      $category->cimage = $image_name;
    }
    $category->save();
    Session::flash('sm', 'Category Is Updated!');

------------------------------------------CATEGORIE REQUEST:----------------------------------
class CategorieRequest extends FormRequest
{

    public function authorize()
    {
        return true;
    }

    public function rules(Request $request)
    {
        $item_id = !empty($request['item_id']) ? ',' . $request['item_id'] : '';
        return [
            'title' => 'required',
            'url' => 'required|regex:/^[a-z\d-]+$/|unique:categories,curl' . $item_id,
            'article' => 'required',
            'image' => 'image'
        ];
    }
}
How to&Answers: