rappasoft / laravel-livewire-tables Goto Github PK
View Code? Open in Web Editor NEWA dynamic table component for Laravel Livewire
Home Page: https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
License: MIT License
A dynamic table component for Laravel Livewire
Home Page: https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
License: MIT License
Pls update to Livewire 2.0.
thx
I'm getting the " You are not currently connected to the internet." even if I'm online
In your readme it says You can override any of these in your table component:
however,
overwrites the properties in constructor. So normal overwrites don't work and you have to do something like:
public function __construct($id)
{
parent::__construct($id);
$this->noResultsMessage = '一致するレコードがありません';
$this->perPageLabel = '件表示';
}
I can see why you need to do it like that, but it might be worth mentioning in the readme.
able data is for multiple users and multiple users are interesting the data in the database but when you show it to the user to look like 5,56,64 more like that which is not good
so I want to show them like the 1,2,3
is there any demo site that we can check in to?
I spent the last few days doing a semi-rebuild and removing some features I don't think I need right now. I need some people to test with the current development branch using the new README on that branch for guidance and report back on if you like this format better.
These are the current release points:
I will probably merge this to master tomorrow, do not update if you are using components or checkboxes.
I have certain rows that I want to be clickable (across the whole row), that redirects to a named route.
I don't want to edit the table blade directly since the route will change based on the table, and some tables wont be clickable at all.
How would I do about doing this? Thanks.
It would be nice to add image component support
At the top of the table, there is drop-down to select number pr. table, it would be nice to be able to turn that off
For now, we must create a new class that extends Column
and use CanBeHidden
trait but it would be great if this package has built-in support.
It will be great if there is button for export to pdf and csv like datatables.
kdion4891/laravel-livewire-tables#23
I have created issue there but i think it is not activly maintained.
when using search or sorting, the language of the page changes
This commit 9808eaa#diff-2ef2020b3a79c6d6648f9af7d16b32b0
cause problems when we add a component and use a closure to determine if we should hide or not a component.
Calling isHidden() on the column will try to return the closure, which is not a boolean.
Maybe pass the $models to isHidden and loop through them to test the closure ?
Hi There!
If i have a relation, say, physicalAddress, laravel encodes that as physical_address in the data if you do toArray, for example.
However, your library doesn't pick that up, so if I change the column to physical_address.city, it works for display, but then sorting is broken because it looks for a relation called physical_address
Not sure if that's expected functionality or not, but wanted to make you aware of the bug.
Hi,
how to make translation for statistics under the datatable ?
1- Showing 1 to 12 out of 12 results
2- Per Page
3- Search
thank you
Currently the complete package is setup for bootstrap. With Laravel 8 the default scaffold for Jetstream is Tailwind CSS.
i think that search operation done in model retrived data from database, but when using view in column mean that additional data added inside the column that not retrived from database, is there a way to make search operation affect in rendered view column?
Hi, just installed to test and noticed that on the page is not the first one, the search returns no results.
But if we go to ?page=2, and search again for "goos" nothing is returned
Classes & attributes do not apply to headers unless they are marked as sortable.
Not sure of the best way to resolve other than duplicating the following:
Unfortunately, the icons are strongly defined in the template. But I love the icons fal and not fas, it would not be bad if it would be made in the settings
The pagination text is a little funky if there is no records to display:
"Showing to out of 0 results"
Hi There!
I have the following component
https://gist.github.com/zack6849/5a025eaa21454c6abecaf5cfbc479ce1
Which I render like this:
<livewire:unit.table :community="$community"></livewire:unit.table>
On page load, the table populates, but if i search it throws an exception
how to create the serial number colum
like
1
2
3
4
5
.
.
.
I store money as cents in my database. When I show it on the screen, I pass it through a money()
helper that converts it to the right currency/format.
Based on the limited docs and other issues I saw that the way to accomplish this was using view()
or components()
. However, despite that being said, there is not an explanation of how either of these works really anywhere, and the examples given are basically duplicates of eachother so I'm not really sure what that's about?
Either way, this seems incredibly heavy handed and a lot of work for the developer to do something as basic as modifying the output.
May I give an alternative solution?
Column::make('price', function ($model) {
return money($model->price);
}),
This is incredibly flexible and way more lightweight than this "component" system, and also way easier for developers to integrate.
Hopefully you can look into it.
Hi
Nice component!
May I suggest that there is a 'default' actions one can like, edit, show,delete ?
some time traversing in pagination take time according to network or size of data, is there away to let loading work also in pagination traverse, thank you
is this package applicable for non database item like reading files & rendering files from storage:disk.
i'm trying to read zipped files from storage
$disk = Storage::disk('path to disk');
$files = $disk->files(str_replace(' ', '-', config('backup.name')));
$item = [];
foreach ($files as $k => $f) {
if (substr($f, -4) == '.zip' && $disk->exists($f)) {
$item[] = [
'file_path' => $f,
'file_name' => str_replace(str_replace(' ', '-', config('backup.backup.name')).'/', '', $f),
'file_size_byte' => $disk->size($f),
'last_modified_timestamp' => $disk->lastModified($f),
];
}
}
$item = array_reverse($item);
return view('backend.backup.index', compact('item'));
I have a many-to-many relationship. I want to sort by a pivot field, but the normal Laravel syntax doesn't work on $sortField
.
pivot.updated_at
for example.
I've confirmed this does exist on my relationship in the pivot
attribute, so I think this is a use-case not covered by the package.
Is it possible we could get this added. :)
in columns function, is there away add view object instead of view blade file ptah, because less greating blade files for actions fileds.
thank you
Not sure if it's a bug
I have a activity Model, and in the model I have this:
protected $casts = [
'updated_at' => 'datetime',
'created_at' => 'datetime',
'activity_date' => 'date',
];
in the column is still rendered as date time and not as date only
Hi,
While testing the "Check All" functionality, I have found a strange behavior.
Now i activate the first three checkboxes.
In the dev console I can see three POST
requests, which is ok - but the size and the needed time seems to be a problem:
Any thoughts how to solve/fix this?
Thanks!
Regards,
Marcus
Hi,
Consider the column "primary" that is true or false. We might want to change the output to display something else instead of 0 and 1, an option that allows to display an icon, image or basicly a string that allow us to do just that. It will nice if we can include the original value in that string also, this will allow adding some icon or formating to the output text,
Cheers and very good work
this happen when i want to use table.column
, always assume relationship and return error
Hi,
search operation start before completing the search keywords, is there a way to let it start after press enter or adding search icon to click on it?
thank you
I'm not entirely sure if this is documentation issue or I'm doing something wrong but when I try something like this
public function columns(): array
{
return [
Column::make('Actions')
->components([
Link::make('Delete')
->view('livewire.includes.delete-button'),
]),
];
}
It throws exception
Call to a member function isHidden() on string
(View: /project/vendor/rappasoft/laravel-livewire-tables/resources/views/includes/_body.blade.php)
(View: /project/vendor/rappasoft/laravel-livewire-tables/resources/views/includes/_body.blade.php)
(View: /project/vendor/rappasoft/laravel-livewire-tables/resources/views/includes/_body.blade.php)
(View: /project/vendor/rappasoft/laravel-livewire-tables/resources/views/includes/_body.blade.php)
This seems to be because view() method in src/Views/Link.php actually returns string. However readme is referring this method as it would work like Column's view() and thus would return $this
for following snippet:
public function query() : Builder
{
return User::with('roles')
->withCount('permissions');
}
public function columns() : array
{
return [
Column::make('ID')
->searchable()
->sortable(),
Column::make('Name')
->searchable()
->sortable(),
Column::make('E-mail', 'email')
->searchable()
->sortable(),
Column::make('Role', 'roles.name')
->searchable()
->sortable(),
Column::make('Permissions', 'permissions_count')
->sortable(),
Column::make('Actions')
->view('backend.auth.user.includes.actions'),
];
}
One user is having more than 1 roles.
How can I uses 'roles' may be lets say I want to display comma separated role names or any other kind of operations, How can I do it?
Thanks
Love this package. I have been using it without issue for a couple of months, but now I am trying to use format
to render linkRoute
output in a cell by following the instructions at https://github.com/rappasoft/laravel-livewire-tables#html-components
I get an error that HtmlComponents cannot be found. When I grep the package under vendor/rappasoft, I don't see it anywhere. Removing its inclusion then throws an error that the format function is undefined. I ran composer update to ensure I was testing against the latest version.
When I comment out format
and HtmlComponents
, the below code works just fine. Any help would be greatly appreciated.
public function columns() : array
{
return [
Column::make('User', 'user.full_name')->customAttribute()
->searchable()
->sortable(),
/*->format(function ($model) {
return $this->linkRoute('admin.users.edit', $model->user->full_name, $model->user_id);
}),*/
Column::make('Status', 'status')
->searchable()
->sortable()
->view('admin.subscriptions.includes.status'),
Column::make('Product', 'product.name_short')
->searchable()
->sortable(),
Column::make('Pricing Tier', 'price.label')
->searchable()
->sortable()
->view('admin.subscriptions.includes.price'),
Column::make('Start Date', 'created_at')
->searchable()
->sortable()
->view('admin.subscriptions.includes.created_at'),
Column::make('Actions')
->view('admin.subscriptions.includes.actions'),
];
}
Laravel version 8
Livewire Tables version 0.3.1
I have the following table:
Column::make('id')
->searchable()
->sortable(),
Column::make('Title')
->searchable()
->sortable(),
Column::make('Min. Bid','MinBid')
->searchable()
->sortable(),
'id' and 'title' are normal fields and sorting works perfectly as expected, 'MinBid' is an accessor defined in the model and when I click it to sort, the table goes back to the default sorting but no actual sorting happens.
Here's the code where accessor is defined:
public function getMinBidAttribute(){
return Auction::where('product_id',$this->id)->min('closing_bid');
}
Thanks for this package!
Hi,
I don't know how to show an attribute of a relationship in a column.
For example, I have a table users and each user has attribute country_id, which is a belongsTo relationship to the countries table. So if I want to show the name of the country and make that column sortable() and searchable(), what do I need to do?
Thanks
when using a package, it is impossible to get an attribute from a field https://github.com/spatie/laravel-translatable
Therefore, for the field, you need to get the json value.
I'd like to be able to be able to do this: "If the main content of a page is a Livewire component, you can pass the component directly into a Laravel route as if it were a controller."
I've worked on this myself and was able to easily add ->layout()
both with and without parameters to the package. However, I got stuck when trying to implement ->slot()
. I'm sure it's a simple thing that I am overlooking. I've just currently run out of time to work on it for now. I'll come back to it when I have more time if no one else figures it out first.
Maybe I'm the only one who wants this. I just thought it'd be a good feature.
In addition to searching, will it be possible to define a filtering column?
More often than not there is a need to filter the table based on values in one of more columns and then search through a scoped result set.
In terms of example provided in documentation:
When typing in the search box, it gets reloaded from blade after a successful search. The expected behavior would be for only the table and and pagination to be reloaded.
(BTW - I love the package - good work)
Just as a comparison i have also kdion4891/laravel-livewire-tables in my test project
even if I create a new page only with your component the page will not render
Steps:
composer require rappasoft/laravel-livewire-tables
composer require kdion4891/laravel-livewire-tables
// This makes the kdion4891 component
php artisan make:table UserTable -Model=User
// This makes your component
php artisan livewire:make RUserTable
Then I have this code for your component
<?php
namespace App\Http\Livewire;
use App\User;
use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\TableComponent;
use Rappasoft\LaravelLivewireTables\Views\Link;
class RUserTable extends TableComponent
{
public function query() : Builder
{
return User::query();
}
public function columns() : array
{
return [
Column::make('ID')
->searchable()
->sortable(),
Column::make('Name')
->searchable()
->sortable(),
Column::make('E-mail', 'email')
->searchable()
->sortable(),
Column::make('Actions')
->addComponent(Link::make('Edit'))
->addComponent(Link::make('Delete'))
];
}
}
I have a /users route in my HomeController
the blade file looks like this:
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<livewire:r-user-table></livewire:r-user-table>
</div>
</div>
@endsection
When loading the page I get the following error:
Undefined variable: header_view (View: /home/vagrant/code/test/vendor/kdion4891/laravel-livewire-tables/resources/views/table.blade.php) (View: /home/vagrant/code/test/vendor/kdion4891/laravel-livewire-tables/resources/views/table.blade.php)
I have tried
php artisan cache:clear
php artisan view:clear
composer dumpautoload
same result
I would normally not have both, but...
I have the following database tables:
shops
– id
– name
products
– id
– name
product_shops
– product_id
– shop_id
How do I use the livewire to create a table based on a shop_id?
Let's say I want to view all the products in the Walmart shop!
The database would look something like this:
product_id | shop_id |
34 | 4
35 | 4
36 | 4
I now need to display in the table, the name of the product, the name of the shop and other info regarding the product!
is there a way to emit loading events on start loading and finishing something like (isLoading), to be able to use custom loading method, thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.