Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug] Filters not working as it does not find views #3093

Closed
iamraju opened this issue Aug 2, 2020 · 9 comments
Closed

[Bug] Filters not working as it does not find views #3093

iamraju opened this issue Aug 2, 2020 · 9 comments
Assignees
Labels

Comments

@iamraju
Copy link

iamraju commented Aug 2, 2020

Bug report

Filters are not working.

What I did

I did upgraded from 4.0 to 4.1, I tried all the steps mentioned in the documentation and tried to visit my listing page (ListOperation). I have couple fields to be available to search/filter.

What I expected to happen

I had expected to work the filters as it is working with 4.0.

What happened

In ListOperation (Listing page), I found the following error message:

InvalidArgumentException
View [text] not found. (View: resources/views/vendor/backpack/crud/inc/filters_navbar.blade.php)

What I've already tried to fix it

When I tried to look at file filters_navbar.blade.php, there is a loop:

@foreach ($crud->filters() as $filter)
    @include($filter->view)
@endforeach

Here $filter->view is returning only view name i.e. text, select2, etc, rather it expects something like crud:filters.text. I found the Trait Filters has been modified a lot and I did not find extra classes in it.

Backpack, Laravel, PHP, DB version

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

PHP 7.4.8 (cli) (built: Jul 13 2020 16:46:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies

### LARAVEL VERSION:
v7.22.4@30e851a2b3a2af73fba0b7f4fa22b04260db98e7

### BACKPACK VERSION:
4.0.61@1977e0cc52fa7cf9547eaeadf03f5cd88402b574

Not sure what I missed to perform.

@welcome
Copy link

welcome bot commented Aug 2, 2020

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 channels:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (How do I do X) - Gitter Chatroom;
  • Long questions (I have done X and Y and it won't do Z wtf) - Stackoverflow, using the backpack-for-laravel tag;
  • Showing off something you've made, asking for opinion on Backpack/Laravel matters - Reddit;

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
Copy link
Contributor

pxpm commented Aug 3, 2020

Hello @iamraju

Actually the code for getting the filters is:

@foreach ($crud->filters() as $filter)

    			@foreach ($crud->filters() as $filter)
    				@include($filter->getViewWithNamespace())
    			@endforeach

My guess is that you have that file published and backpack is picking the one you override in resources instead of the one in the package.

It could be a cache problem php artisan cache:clear or some composer issue. Try composer dump-autoload.

I don't think this is a bug, so I am going to close this. If you still feel this is a bug, please re-open.

Best,
Pedro

@pxpm pxpm closed this as completed Aug 3, 2020
@iamraju
Copy link
Author

iamraju commented Aug 3, 2020

Hi There,

Thanks for taking care of the issue I posted.

Yes, later I found that the code is changed but strange part is; even when published new views, is there a way to re-publish all the view files ? I see a command backpack:publish <subpath> for publishing one particular view though.

@pxpm
Copy link
Contributor

pxpm commented Aug 3, 2020

@iamraju There is no command to publish all the the Backpack view files. I don't think publishing ALL Bacpack views is a good pratice. I think publishing only the ones you are going to change makes more sense.

Best,
Pedro

@iamraju
Copy link
Author

iamraju commented Aug 3, 2020

@pxpm I do totally agree in general it is not good to publish all but I am not sure what files are/were modified and hence I just wanted to republish all.

Now the filter fields problem resolved, it works but now buttons giving trouble. Like I cannot see button to Create New model in the listing page. I tried re-publishing the crud/inc/button_stack file but that did not help.

By the way, one small correction you guys need to make is; the example in arguments of the command backpack:publish says fields/text but that did not help in case of inc/button_stack instead I had to do crud/inc/button_stack

Thank you again for responding.

@pxpm
Copy link
Contributor

pxpm commented Aug 3, 2020

@iamraju if you are not doing customization in the files you could just delete them from your resources folder and backpack will pick the ones in the package. It's kind of the same of publishing all files and overwrite the changes so ...

About the publishing you should look at backpack folder structure and give the appropriate path to the file you want to publish. fields/text is just an example for the text field.

Best,
Pedro

@iamraju
Copy link
Author

iamraju commented Aug 3, 2020

Thanks @pxpm for continuous reply !

But even when I deleted all the published files/folders, I cannot see buttons, not sure where and what happened. I am exploring myself the codebase but if you have any direction to point to, that would save my time !

@pxpm
Copy link
Contributor

pxpm commented Aug 3, 2020

My guess then is that you need to re-publish backpack assets and clear caches.

Check step 13 of upgrade guide: https://backpackforlaravel.com/docs/4.1/upgrade-guide#step-13

Then clear your caches: php artisan view:clear

Best,
Pedro

@iamraju
Copy link
Author

iamraju commented Aug 3, 2020

That did not help either. I tried that running the commands in step 13.

Actually I tried dd($this->crud->buttons()); in setup() function of a controller lets say EmployeesCrudController then it returns :

Illuminate\Support\Collection {#2343 ▼
  #items: []
}

So it should be something in the framework itself or another doubt permission stuffs on which I am yet to check in details.

By the way, this is happening only in my upgraded project (4.0 to 4.1), but it is working in fresh/new installation.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants