Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.15k stars 891 forks source link

[4.0.x][Bug] Crud views are broken (Laravel 6.2) #2143

Closed AforDesign closed 5 years ago

AforDesign commented 5 years ago

Bug report

What I did

New Laravel 6.x + Backpack v4.x installation

What I expected to happen

Nice panel views like in the demo

What happened

Appearently the new CRUD views have a different structure then the BASE views. This results in missing classes, different wrappersr, and missing stylesheets, fonts and scripts.

Without any modification, the CRUD views look like:

Schermafbeelding 2019-10-11 om 11 41 47 Schermafbeelding 2019-10-11 om 11 42 20

What I've already tried to fix it

I've overridden the top_left.blade.php template with a customized version in my resourcemap to make it look more like the rest.

This file can be found in the CRUD package in 'src/resources/views/base/layouts/top_left.blade.php'

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 7.2.1 (cli) (built: Jan 15 2018 12:20:50) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies

LARAVEL VERSION:

laravel/framework v6.2.0 The Laravel Fram...

BACKPACK VERSION:

backpack/backupmanager 1.4.10 Admin interface ... backpack/base 1.1.13 Laravel Backpack... backpack/crud 4.0.7 Quickly build an... backpack/generators 1.2.7 Generate files f... backpack/logmanager 2.3.27 An interface to ... backpack/permissionmanager v4.x-dev 65a7775 Users and permis...

welcome[bot] commented 5 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

samuk190 commented 5 years ago

My crud is working in laravel 6.0. When this happens it seems a version of your base is different for your crud.

Your backpack generator is version 1, while there're version 2 for laravel 6 your backpack base is version 1, while there're version 2 for laravel 6 too.

paste this on your composer json require

"backpack/backupmanager": "^2.0",
    "backpack/crud": "^4.0",
    "backpack/logmanager": "^3.0",
    "backpack/pagemanager": "^2.0",
    "backpack/permissionmanager": "^5.0",
    "backpack/settings": "^3.0",
    "barryvdh/laravel-elfinder": "^0.4.3",
    "fideloper/proxy": "^4.0",
       "jlapp/swaggervel": "dev-master",
    "laravel/framework": "^6.0",
    "laravel/tinker": "^1.0",
    "laravel/ui": "^1.0",
    "laravelcollective/html": "^6.0",
    "lavary/laravel-menu": "^1.7",
    "yajra/laravel-datatables-buttons": "^4.0",
    "yajra/laravel-datatables-oracle": "^9.6"

and in your require-dev "require-dev": { "backpack/generators": "^2.0", "facade/ignition": "^1.4", "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", "nunomaduro/collision": "^3.0", "phpunit/phpunit": "^8.0", "sven/artisan-view": "^3.3"

run composer update, and publish all files again. it will fix everything

tabacitu commented 5 years ago

Indeed, Backpack/CRUD 4.x does NOT need Backpack/Base. I see you have both installed, so that must be the problem - both Base and CRUD define layouts etc, there's a conflict and your app seems to be picking up the CSS and JS from Base when it should be picking up those from CRUD.

Remove Backpack/Base from your composer.json, then run composer update and php artisan view:clear, that should fix it for you.

@AforDesign can you please tell me which guide you used to install Backpack? The link please? There must be a problem there where you're instructed to install Base, but I can't find that anywhere. Thanks!

samuk190 commented 5 years ago

Indeed, Backpack/CRUD 4.x does NOT need Backpack/Base. I see you have both installed, so that must be the problem - both Base and CRUD define layouts etc, there's a conflict and your app seems to be picking up the CSS and JS from Base when it should be picking up those from CRUD.

Remove Backpack/Base from your composer.json, then run composer update and php artisan view:clear, that should fix it for you.

@AforDesign can you please tell me which guide you used to install Backpack? The link please? There must be a problem there where you're instructed to install Base, but I can't find that anywhere. Thanks!

thanks for your reply, I didnt know that, maybe thats the reason I have a field bug in my project

AforDesign commented 5 years ago

Thanks for the quick replies. My holidays just started, so I haven't had much time to look into it untill now.

I've removed the 'Base' entry from composer.json, cleared the vendor directory and ran the composer update. Cleared all caches. It did not help though.

@tabacitu I've followed the instructions on: https://backpackforlaravel.com/docs/4.0/installation

Also I've installed the following official addons: PermissionManager Settings PageManager LogManager BackupManager

If I go to my Category admin (my most basic model with crud atm), the following views are loaded (copy pasted from debugbar):

crud::list (vendor/backpack/crud/src/resources/views/crud/list.blade.php)2blade crud::inc.button_stack (vendor/backpack/crud/src/resources/views/crud/inc/button_stack.blade.php)9blade crud::buttons.create (vendor/backpack/crud/src/resources/views/crud/buttons/create.blade.php)12blade crud::buttons.reorder (vendor/backpack/crud/src/resources/views/crud/buttons/reorder.blade.php)12blade crud::inc.datatables_logic (vendor/backpack/crud/src/resources/views/crud/inc/datatables_logic.blade.php)11blade crud::inc.export_buttons (vendor/backpack/crud/src/resources/views/crud/inc/export_buttons.blade.php)11blade crud::inc.details_row_logic (vendor/backpack/crud/src/resources/views/crud/inc/details_row_logic.blade.php)11blade backpack::layouts.top_left (vendor/backpack/crud/src/resources/views/base/layouts/top_left.blade.php)11blade backpack::inc.head (vendor/backpack/base/src/resources/views/inc/head.blade.php)11blade backpack::inc.main_header (vendor/backpack/base/src/resources/views/inc/main_header.blade.php)11blade backpack::inc.menu (vendor/backpack/base/src/resources/views/inc/menu.blade.php)11blade backpack::inc.topbar_left_content (vendor/backpack/base/src/resources/views/inc/topbar_left_content.blade.php)11blade backpack::inc.topbar_right_content (vendor/backpack/base/src/resources/views/inc/topbar_right_content.blade.php)11blade backpack::inc.sidebar (vendor/backpack/base/src/resources/views/inc/sidebar.blade.php)11blade backpack::inc.sidebar_user_panel (vendor/backpack/base/src/resources/views/inc/sidebar_user_panel.blade.php)11blade backpack::inc.sidebar_content (resources/views/vendor/backpack/base/inc/sidebar_content.blade.php)11blade backpack::inc.breadcrumbs (vendor/backpack/crud/src/resources/views/base/inc/breadcrumbs.blade.php)11blade backpack::inc.footer (vendor/backpack/base/src/resources/views/inc/footer.blade.php)11blade backpack::inc.scripts (vendor/backpack/base/src/resources/views/inc/scripts.blade.php)11blade

So, there are still a lot of base views loaded.

My Controller: `<?php

namespace App\Http\Controllers\Admin;

use App\Http\Requests\CategoryRequest; use Backpack\CRUD\app\Http\Controllers\CrudController; use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;

/**

`<?php

namespace App\Models;

use Backpack\CRUD\app\Models\Traits\CrudTrait; use Illuminate\Database\Eloquent\Model; use Spatie\Sluggable\HasSlug; use Spatie\Sluggable\SlugOptions;

class Category extends Model { /* -------------------------------------------------------------------------- TRAITS
*/
use CrudTrait;
use HasSlug;

/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'categories';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
 protected $fillable = [
     'ref',
     'name',
     'slug'
 ];
// protected $hidden = [];
// protected $dates = [];

/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/**
 * spatie/laravel-sluggable
 * Get the options for generating the slug.
 */
public function getSlugOptions() : SlugOptions
{
    return SlugOptions::create()
        ->generateSlugsFrom('name')
        ->saveSlugsTo('slug');
}

/**
 * spatie/laravel-sluggable
 * Get the route key for the model.
 *
 * @return string
 */
public function getRouteKeyName()
{
    return 'slug';
}

/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/

} `

Next weekend I'll be able to start a completely fresh install and watch if the problem occurs again and at which point.

tabacitu commented 5 years ago

Hmm that's weird @AforDesign . I have a number of projects upgraded from Backpack 3.x to 4.0 and they work fine. So there shouldn't be a need for you to start from scratch. Something must be off here.

Your controller, model, look ok. What does your composer.json look like?

ApexMuse commented 5 years ago

@AforDesign - I had this same issue while going through the upgrade process. Make sure to focus on this section in the upgrade guide, particularly steps 15 & 16.

AforDesign commented 5 years ago

@ApexMuse Yesss! Thank you for pointing out these instructions.

Although I didn't update from v3.x, but started with v4.0 for my project, it still helped me. The update instructions contained the step(s) that fixed my issues.

It weren't step 15 & 16 that made a difference, so I decided to check each step of this update instruction.

2 things caught my attention:

  1. In my setup, my crud config file looked very different, so I replaced it with the one linked in the instruction manual.
  2. In my require-dev section, the backpack/generator was set to v1.2.4. (but it was v2.0 when I started this topic. Don't know what changed it)

So, thanks alot everyone! I wish I could pinpoint what exactly caused the problem, but it looks like something went wrong in the original installation, without error notification. My guess would be that the problem layed within the crud-config file. My version didn't have the correct structure of the operation settings.

ps. shall I close this issue, or should it stay open for further investigation?

tabacitu commented 5 years ago

Thanks for the update @AforDesign ! Closing it.

If anybody else faces the same problem, please reply and we'll reopen the issue.