Laravel Backpack Multi Level Data Table - laravel

I wanted to implement multi level data table structure with Laravel Backpack. Please see the images for more information
structure - https://ibb.co/i9Qfud
initial view - https://ibb.co/h8SFSy
trip expanded - https://ibb.co/cm027y
city expanded - https://ibb.co/ej3N7y
day expanded - https://ibb.co/iGffud
Is this possible with Laravel backpack ? Any references where i can find a solution?
Thanks in advance :)

There's a Backpack functionality called Details Row that will help you achieve the first [+] button, but I'm afraid that's about it - the next ones are up to you.
You will have to:
in your TripCrudController::setup():
$this->crud->enableDetailsRow();
$this->crud->allowAccess('details_row');
$this->crud->setDetailsRowView('details_row.expanded_trip_details_row');
create the blade file that outputs the table with cities, days and attractions (let's say resources/views/vendor/backpack/crud/details_row/expanded_trip_details_row.blade.php); shouldn't be very difficult, you have the current trip as $entry inside this file and you can drill down using Eloquent relationships into $cities = $entry->cities, then $days=$city->days etc;
include some javascript so that subsequent [+] signs work, inside your public/vendor/backpack/crud/js/list.js; alternatively, you could do this with inline javascript inside the same blade file, might be cleaner that way; but remember that this blade content is put inside the details row with AJAX, so new DOM elements and events need to be registered;
Hope it helps.

Tabacitu has provided the right answer but i've observed in my case that the details_row template should be called this way :
$this->crud->setDetailsRowView('backpack::crud.details_row.expanded_trip_details_row');

Related

How to add another table column in searchable array in nova?

i am getting data from different different tables and i displayed all those in one section that section contains search button also, i want to add another resource field as a searchable item in nova ,i am trying to add based on the relation of the particular table but it's throwing an error undefined column, How to add please help..
public static $searchable=['id','name','account.type'];
Basically, the search by relationship is not possible through Nova.
A package well made for your needs is this one: LaravelNovaSearch
This package includes both relationship search but also has other useful features making the search much more comprehensive.
Another package, which I have not personally tested, but which seems to be useful for your needs: NovaSearchRelations
My advice is to use LaravelNovaSearch, more maintained and more complete.

Laravel: A field that lookup another field from different table

I use Backpack for Laravel.
I know that to add a field, we can use:
CRUD::addField(['name'=>..])
But, I don't know how to add a field that lookup another field input from different table to show a lookup value.
Please look at the illustration below.
Thanks.
Edit:
I found a temporary solution to this, but not effective.
Reference: https://backpackforlaravel.com/docs/4.1/crud-how-to#add-a-select2-field-that-depends-on-another-field
With select2_from_ajax you still have to select the option (even its just one option left), meanwhile what I really want is its automatically select that one option.
It's depends on what you need to do. You can use relationship field and show a select with the list of user. If you really wanna do it like this. You can probably make an ajax request to show it. In that case you ll need to use a custom view for the edit or the create view.

Displaying user avatar foreach post in Laravel 5.5

I'm actually working in a little forum project, everything is fine till I was stuck in a problem.
I want to display the user Image in front of every post he creates.
I have a table called discussion and another called users and each one of them contains the "user_id" column, but I couldn't figure out how to link them.
firstly you need to know about relation ship between the database table. then you need to learn about eloquent relationship on laravel docs.
https://laravel.com/docs/5.6/eloquent-relationships

ember persistantly save sorted model

I am using this drag and drop addon for ember: ember-drag-drop
So far so good, this works as expected.
I copied the controller- and template code from the demo (ember-data) and adapted it to my model. In my template the records of my model are sorted with drag and drop and are displayed in another list on this site correctly (is updating at the same time as the drag and drop list).
Now, what should I do to permanently save my sorted records ?
Somehow this model must have changed, otherwise the other list would not recognise this or am I wrong ?
Maybe anyone who used this addon came across this, too.
Normally, my records are stored in local storage. For that, I use the ember-local-storage-adapter.
I tried the following:
My model is called buttons. Inside the model there are several records.
const store = this.get('store');
store.findAll('buttons').then(function(sorted){
console.log(sorted);
sorted.save();
});
It seems that with this I only get the old model from the local storage but actually I need the most recent model that lives somewhere on the site.
I hope you understand, what I am struggeling with my mind is running out with all these model stuff.
Thanks for any help and suggestions!

How VirtueMart sends the data when you save the custom fields in a product

first of all, sorry for my english, but I'll try to explain myself best I can.
My question is little tricky, because I made some important changes in the core code of VirtueMart.
For some reasons, I added an attribute to the Custom Fields, like Price, called Availability.
TIP: The admin site is in Spanish. Disponibilidad = Availability
So, now, when I try to change any value of any created Custom Field, I can't save it. I mean, I can change the value, but when I apply them, It doesn't be saved.
The only field that I can change, is the field I created, the Availability (ironically).
So, my principal question is, how does VirtueMart to pick up the data from the table and sends them to the database?
I work with
Joomla v.2.5.11
VirtueMart 2
Thanks
The workflow is like follows,
When you save the products details on the backend , It calls a function store() on the product.php model. under administrator/components/com_virtuemart/models/. Inside this function an area like follows.
if(!class_exists('VirtueMartModelCustom')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'custom.php');
VirtueMartModelCustom::saveModelCustomfields('product',$data,$product_data->virtuemart_product_id);
It loading the custom model file from the same path and do the task inside saveModelCustomfields()
Hope it helps..

Resources