You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -26,10 +27,10 @@ Laravel package to create beautiful common views like tables using only PHP code
26
27
-[Roadmap](#roadmap)
27
28
28
29
# Version compatibility
29
-
|Laravel views|Livewire|Laravel|
30
-
|-|-|-|
31
-
|2.x|2.x|7.x, 8.x|
32
-
|1.x|1.x|5.x, 6.x|
30
+
|Laravel views|Alpine|Livewire|Laravel|
31
+
|-|-|-|-|
32
+
|2.x|2.8.x, 3.x.x|2.x|7.x, 8.x|
33
+
|1.x|2.8.x|1.x|5.x, 6.x|
33
34
34
35
# Installation and basic usage
35
36
@@ -59,12 +60,13 @@ Add the following Blade directives in the *head* tag, and before the end *body*
59
60
</html>
60
61
```
61
62
62
-
These blade directives are also including [Laravel livewire](https://laravel-livewire.com/) and [Tailwindcss](https://tailwindcss.com/) styles and scripts, after that you may need to clear the view cache
63
+
Laravel Views includes by default a set up using different parts of the TALL stack assets like the [Laravel livewire](https://laravel-livewire.com/) and [Tailwindcss](https://tailwindcss.com/) styles and scripts, it alsoincludes the [Alpine.js](https://laravel-livewire.com/docs/2.x/alpine-js) script, after adding these directives you may need to clear the view cache
64
+
63
65
```bash
64
66
php artisan view:clear
65
67
```
66
-
If you are already using your own Tailwindcss setup you can set `laravel-views` to not importing Tailwindcss by default. ([Importing assets](./doc/laravel-views#including-assets))
67
68
69
+
These directives are fine for a dev environment, however, if you want to use your own Tailwindcss or Alpinde.js setup, you can [disable these assets](./doc/laravel-views.md#including-assets) from being loaded with the Laravel views directive.
68
70
# First table view
69
71
This is a basic usage of a table view, you can [read the full table view documentation ](doc/table-view.md)
With this artisan command a UsersTableView.php file will be created inside the `app/Http/Livewire` directory.
77
79
78
-
The basic usage needs a data repository (Eloquent query), headers and rows, you can customize the items to be shown, and the headers and data for each row like this example
80
+
The basic usage needs a model class, headers and rows, you can customize the items to be shown, and the headers and data for each row like this example
79
81
```php
80
82
<?php
81
83
@@ -87,10 +89,7 @@ use App\User;
87
89
88
90
class UsersTableView extends TableView
89
91
{
90
-
public function repository(): Builder
91
-
{
92
-
return User::query();
93
-
}
92
+
protected $model = User::class;
94
93
95
94
public function headers(): array
96
95
{
@@ -128,7 +127,7 @@ You could also use the `@livewire` blade directive.
128
127
129
128
At this point, you would be able to see a table with some data, the table view doesn't have any styled container or title as the image example, you can render the table view inside any container you want.
130
129
131
-
In the example above the view is using the User model created by default in every Laravel project, feel free to use any model you have, the method `row` is receiving a sinlge model object and you can use any property or public method you have difined inside your model.
130
+
In the example above the view is using the User model created by default in every Laravel project, feel free to use any model you want, the method `row` is receiving a sinlge model object and you can use any property or public method you have difined inside your model.
132
131
133
132
This is the basic usage of the table view, but you can customize it with more features.
134
133
@@ -177,4 +176,57 @@ Here's the plan for what's coming:
177
176
- Add tooltips to actions buttons
178
177
- Add a download action
179
178
- Add translations
180
-
- Add links as a UI helpers
179
+
- Add links as a UI helpers
180
+
181
+
## Upgrade guide
182
+
### From 2.2 to 2.3
183
+
**Cached views**
184
+
185
+
The blade directives have changed, you need to clear the cached views with `php artisan view:clear`
186
+
187
+
**Public assets**
188
+
189
+
The main assets (JS and CSS files) have changed, you need to publish the public assets again with `php artisan vendor:publish --tag=public --provider='LaravelViews\LaravelViewsServiceProvider' --force`
190
+
191
+
**Publish blade componentes**
192
+
193
+
Some of the internal components have changed, if you have published these components before to customize them, you will not have them up to date, unfourtunately you need to publish them again with `php artisan vendor:publish --tag=views --provider='LaravelViews\LaravelViewsServiceProvider'` and customize them as you need.
194
+
195
+
**Method `renderIf()` in actions**
196
+
197
+
Update the renderIf() function in your action classes adding a new `$view` parameter as follows:
198
+
```php
199
+
<?php
200
+
201
+
namespace App\Actions;
202
+
203
+
use LaravelViews\Actions\Action;
204
+
use LaravelViews\Views\View; // new line
205
+
206
+
class YourAction extends Action
207
+
{
208
+
public function renderIf($item, View $view) // add the view parameter
209
+
{
210
+
// your content
211
+
}
212
+
}
213
+
```
214
+
**Publish config file (Optional)**
215
+
216
+
Some new variants have been added to the config file, if you have published the config file before, you could publish it again so you can customize the new variants, this doesn't affect anything at all since the new variants will be taken from the default config file.
217
+
218
+
**Remove `repository` method from your views (Optional)**
219
+
220
+
If your `repository()` methods are returning a query object without any other query applied like `User::query()`, you can define a `protected $model = User::class;` instead, this is the default behavior now, the `repository()` method is still working so you don't need to change anything if you don't want to.
0 commit comments