How to make deep nest resources in Laravel filament - php

I am using filament php as a dashboard
I have the following relations in my codebase
Material Selection > Quotation > Addendums
So material selection has many quotations and Quotation Has Many addendums.
I Am trying to represent this as resources in filament
I can’t use relation manager here because relation manager nest only
one resource , so it ends like this MaterialSelection > Quotations
So is there any way to add nested resources in filament
So I can access Material Selection view page then I can see a button
redirects me to the listing page of quotations and whenever I open
the quotation view page I can see a button that redirects me to
addendums listing page and so on and each one of these is a full resource.
so I can make use of everything that the resource provide ?
Thanks all
I can do that by making custom livewire pages but it would be great if there is any workaround this

Related

Laravel Backpack custom CRUD namespaces for multiple panels

First I'm gonna explain what I'm planning to do and what I've done so far, then tell you what problems I've encountered.
I'm building a panel which covers an admin, a seller and a customer panel.
The admin panel isn't much of a trouble since I'll be using the Backstrap views.
But for the other two the designs are completely different eg login forms, button styles, tables, pagination etc.
The way that I intend to implement this is to publish some of backpack codes and put them in customer/seller directories in order to keep them clean. This image might give you an example:
Notice that the files are in seller/ directory which isn't the default path. The default path based on the docs is something like this: resources\views\vendor\backpack\.
Since the DataTables for lists have different styles, I had to publish datatables_log.blade.php as well and include it in my list.blade.php like this:
which overrides the default line which was something like #include('crud::inc.datatables_logic')
Problem: By doing this, when I create a new CRUD like Products and want to show my customized create button, I'm gonna have to hide the default create button:
CRUD::removeButton('create');
and use this code to show the customized button:
CRUD::addButton('top', 'create', 'view', 'vendor.backpack.seller.crud.buttons.create', 'end');
which is quite cumbersome. Is it possible to declare something like backpack::seller::crud and use it for sellers (as well as something similar for customers) and leave the default namespace for admins intact so that they don't interfere with each other? If so, how would I be able to use it?
Question: Is this approach entirely wrong and there's something that I missed which would've made my life easier?

How to avoid query duplication when using view composers?

I'm using Laravel 5.1.
I have many views which somehow included in each other. For example, I have the main layout, some modal windows, some custom pages. So basically I have N views.
Let me show you a concrete example. The layout.blade.php is basic layout. The companies/index.blade.php is company list. The modals/companies/create.blade.php is a modal template which is included in layout.
Imagine I have a list of company industries. I need to provide the list to the modals/companies/create.blade.php and to the companies/index.blade.php. The list shouldn't be passed from the controller, because it's kind of code duplication and the list is not related to any conditions, so I don't want to pollute controllers with the same lines of code.
So I have a view composer service provider where I link view composers to views. I may have two approaches:
Each view composer represents small part of data, like "IndustriesViewComposer" which serves industry list
Each view composer represents all data necessary for some view, like "CreateCompanyModalViewComposer"
When I tried the first way my service provide file looked like:
'App\ViewComposers\IndustriesViewComposer' => [
'modals.companies.create',
'modals.companies.edit'
... some other views ...
],
In this case if some of the views are included in the same view the query which retrieves industry list will be duplicated. So if I have many small view composers and corresponding views, then the queries are duplicated in case I include those views together. Since I have many modals which are included together I get the duplication.
In the second way I have exactly one view composer for one view. Same situation happens here. For example, I know that I need to provide industry list for company creation modal, and the same list I need to provide to company edition modal.
View sharing for composers won't work since I need to provide the data only for specific pages for users who is logged in.
So basically the question is: how to execute one query for multiple views in case the views are rendering in the current request and avoid duplication.
Imagine I have a single company page.
1) In every page of my system I have company creation modal which needs industries list
2) In single company page I include company edition modal which needs industries list
3) Single page also need industries list
How to retrieve the list only once and provide it to single view, new company modal and edit company modal views?
You can use a middleware. In the middleware you make a query and save the model (or collection) with a bind to IoC Container.
So, in your middleware you can do (for example):
$my_data = Data::where('some_field','some_value')->first();
App::instance('my_data_saved', $my_data);
do not forget to include the use App;
After that you can access the data where you want (controllers, views, etc.) with IoC Container, for example:
<title>{{ App::make('my_data_saved')->title }}</title>
Then you only need include the middleware in your routes or controllers where need the data for your views.

list all products and link each category grid with category box in opencart

I want to load all categories grids on one page and want all products to be available on scroll down. currently I need to click on each category and the page refreshes for each category. This is the site I am working on(ahmad.esy.es). I want this type of functionality upon clicking the category(http://www.just-eat.co.uk/restaurants-hertsplaice-en11/menu#2254). kindly suggest me what changes should I make in view files (product.tpl, category.tpl) or controller files(product.php, category.php). how can I load all the grids of categories in one page
I didn't look at the site you have posted above - if you cannot describe your issue by words or by submitting a code or image it should be improved.
From what I understand you just want an infinite scroll to display all the products you have in your eshop. It is not mentioned whether you want to preserve the default functionality (category tree with products attached to certain categories) or whether you want only this one listing - basically it does not matter - so I will describe in short how to add such new functionality.
The model
you do not need to touch any model - you can reuse the method ModelCatalogProduct::getProducts()
this will give you the possibility to sort or filter the products except you will have to omit the filter_category_id to load all the products
The controller
feel free to create a new controller (e.g. ControllerProductInfinite) or just to reuse one of the already existing - either ControllerProductCategory or ControllerProductProduct
all you need is basically the same as in ControllerProductCategory::index() except adding filter_category_id into a array passed when calling ModelCatalogProduct::getProducts() and a new template for rendering
The template
create a new template that will meet your expectations and infinite scroll requirements
stick to any infinite scroll plugin/implementation you like (may Google be with you)

Drupal 7: Multi Layer Map and Passing multiple NIDs from Views

A noob here (2-month old, literally, Drupal-PHP user)
What I am trying to accomplish:
1.1. A map that shows multiple locations as the user chooses them.
Therefore, the map can show 0-100+ of locations depending on the choice/selections that user makes
These locations will be under 1 (one) content_type (ie: business) each with unique NID
On the other word, the business location markers should be toggle on and off, individually (keeping the previous locations choices)
1.2. On the same map, the user can then choose one (or multiple) bus routes. When user chooses different bus route, the location markers (from #1.1 above) will stay on the map
Bus routes will be under another content_type with their own NID
What I had done so far:
2.1. Using OpenLayers module to create the map
2.2. Using Views module to display the map, setting up contextual filter so it can show multiple markers (reqd #1.1)
2.3. Using Views module to display the list of business locations, rewriting the outputs to it point to the URL of the view from #2.2 above
What I still CAN NOT do:
3.1. Creating a view where the list of the business locations are in the form of checkboxes, so the user can choose which locations to show (ideally it should be AJAX-y so the user does not need to press the submit button, but the map marker will toggle on-off as user checks and unchecks the location)
3.2. After #3.1 above is accomplished, do the same thing with the bus route
What I had tried so far:
4.1. Installing couple of View-helper modules, like BEF, VBO, and such
4.2. Try to create a theme the view jumpdown style plugin --> utterly fail as I do not know enough Drupal nor PHP
Can not get this to work: http://www.civicactions.com/blog/2011/apr/15/filtering_a_view_by_a_list_...
Please help:
5.1. to educate me how to create a custom Views Style Plugin (creating checkboxes)
5.2. how to pass the values (NIDs) of the checkboxes to the URL (contextual filter) dynamically
Will it be helpful if I give you the URL of the page I am trying to develop?
I am also open to use different Mapping module if that one has the feature I need
Thank you in advance,
PS: have posted this on the Drupal forum, got no answer so far
Hopefully, this link will help me convey what I am trying to do:
http://link2.cswebdevelopers.com/map-of-lm_locations
On the page above, I can choose ONE location at the time and the map will show a yellow marker. I am using Views 3 and OpenLayer modules
What I would like to do is to have the dropdown or the unordered list on the left sidebar become CHECKBOXES so the user can check and uncheck 1 or more locations and the map will show 1 or multiple markers as appropriate.
Thank you

Joomla ACL for specific view in custom component

I've written an extension and I'm now trying integrate it into the ACL. I've been using the documentation here: http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Adding_ACL
Thus far I've been able to set access for the entire component but what I really want is to enable one user group to perform actions on a certain "view", if you will, while another group is denied access to that particular view. I'm guessing it's what's explained here: http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Adding_ACL#Adding_more_actions.2C_also_at_category_level_and_item_level
The problem I'm having is when I click the Options button and change the access options and save, the selected options aren't saved. I've added the asset functions in my table-class and I've added the asset_id column in my table.
http://i50.tinypic.com/ofsjtt.png
Does anyone know what I'm doing wrong? Is it even possible to separate permissions like this?
The viewing access level is called "ViewLevels" http://docs.joomla.org/Access_Control_List/2.5/Tutorial#ACL_View_Access_Levels_Examples.
If you want people to perform certain actions on certain items, then you need to create an other set of permissions for these items different than the component acl.
For example you have a shop component, you have ACL for the component but you can have ACL for the product categories only.

Categories