Laravel-Backpack / NewsCRUD

An admin panel for news with categories and tags, using Backpack CRUD on Laravel 10
http://backpackforlaravel.com
Other
233 stars 51 forks source link

Error 500 by page /admin/tag or admin/article #65

Closed staixe closed 2 years ago

staixe commented 2 years ago

Bug report

What I did:

i install newscrud by method A, i replaced Backpack\NewsCRUD\app with App, then i created the file in directory routes/backpack/newscrud.php with Route::group(['prefix' => config('backpack.base.route_prefix', 'admin'), 'middleware' => ['web', 'auth'], 'namespace' => 'App\Http\Controllers\Admin'], function () { // Backpack\NewsCRUD Route::crud('article', 'ArticleCrudController'); Route::crud('category', 'CategoryCrudController'); Route::crud('tag', 'TagCrudController'); });

What I expected to happen:

I wanted to see the categories or articles page

What happened:

admin/tag, admin/category, admin/article error 500

Backpack, Laravel, PHP, DB version:

backpack 5, php 8.1, laravel 9

welcome[bot] commented 2 years ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

pxpm commented 2 years ago

@staixe I am sorry, I don't understand what you mean that you replaced Backpack\NewsCRUD\app with App.

Can you please re-phrase your question ? You should not be touching any vendor files at any time.

Cheers

staixe commented 2 years ago

@pxpm In the documentation, point 3 says "Replace all mentions of 'Backpack\NewsCRUD\app' in the pasted files with your application's namespace ('App' if you haven't changed it):" I don't have a backpack pro

pxpm commented 2 years ago

Haa ok, can you share with me the error message ? I guess you probably missed to change in some place (maybe models relationship names etc).

Cheers

staixe commented 2 years ago

A have error 404 Page not Found by addresses admin/tag admin/category admin/article

pxpm commented 2 years ago

Did you changed the routes in your controller ->setRoute() definition ? Also clear route cache with php artisan route:clear and post the result of php artisan route:list.

Cheers

staixe commented 2 years ago

Thanks for the help. I did php artisan route:clear Then I moved the route from routes/backpack/newscrud.php to routes/web.php How to make the route stay in the folder routes/backpack/newscrud.php? The page is now opening, it remains to deal with the fields backpack pro

pxpm commented 2 years ago

You could add the routes in routes/backpack/custom.php. Since you are going to override the package files, you can probably also move the package dependencies like spatie-permissions etc into your own composer.json and completely remove the backpack/newscrud package.

web.php don't apply the backpack middleware config('backpack.base.middleware_key', 'admin'). You can use the backpack_middleware() helper function to get the middleware key to apply in routes.

Check an example in our demo on how we disable certain routes in permissionmanager addon: https://github.com/Laravel-Backpack/demo/blob/main/routes/backpack/permissionmanager.php

I am going to close this, I don't think there is any bug here, some misconfiguration I guess. I've been wrong other times, if that's the case and you still think this is a bug, please re-open.

Let me know if I can help you with something else.

Cheers