Skip to content

Commit 90d6a64

Browse files
authored
Merge branch 'release/2.4.0' into editable
2 parents 86450a3 + fb1ed86 commit 90d6a64

File tree

113 files changed

+3718
-1780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3718
-1780
lines changed

.github/workflows/run-tests.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: run-tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- dev
8+
- release/**
9+
- feature/**
10+
- tests/**
11+
pull_request:
12+
branches:
13+
- master
14+
- dev
15+
- /^release-.*$/
16+
- /^release/.*$/
17+
- /^feature/.*$/
18+
- /^tests/.*$/
19+
20+
jobs:
21+
test:
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
fail-fast: true
25+
matrix:
26+
os: [ubuntu-latest]
27+
php: [7.3, 7.4, 8.0]
28+
laravel: [7.*, 8.*]
29+
stability: [prefer-stable]
30+
include:
31+
- laravel: 8.*
32+
testbench: ^6.6
33+
- laravel: 7.*
34+
testbench: ^5.0
35+
36+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - Testbench ${{ matrix.testbench }}
37+
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v2
41+
42+
- name: Setup PHP
43+
uses: shivammathur/setup-php@v2
44+
with:
45+
php-version: ${{ matrix.php }}
46+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
47+
coverage: none
48+
49+
- name: Setup problem matchers
50+
run: |
51+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
52+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
53+
54+
- name: Install dependencies
55+
run: |
56+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
57+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
58+
59+
- name: Execute tests
60+
run: vendor/bin/phpunit

.travis.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"bladeFormatter.format.indentSize": 2,
3+
"bladeFormatter.format.wrapAttributes": "force"
4+
}

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## [2.2.3] - 2021-06-26
4+
### Added
5+
- Default value for filters
6+
- Sortable list and grid views
7+
- Bulk actions to the table, list, and grid views on the current page
8+
- Customized JS scripts
9+
- Model class property to the table, list, and grid views
10+
11+
### Changed
12+
- Internal refactors
13+
- UI improvements
14+
15+
## [2.2.5] - 2021-05-29
16+
### Fixed
17+
- Added a `min-h-screen` to all the views to avoid the filters menu cutting off when thre are not so much data.
318
## [2.2.4] - 2021-05-16
419
### Fixed
520
- Fixed alert container to avoid blocking the UI elements.

README.md

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Laravel package to create beautiful common views like tables using only PHP code
99
![](doc/laravel-views.png)
1010

1111
- [Version compatibility](#version-compatibility)
12+
- [Upgrade guide](#upgrade-guide)
1213
- [Installation and basic usage](#installation-and-basic-usage)
1314
- [Installing laravel views](#installing-laravel-views)
1415
- [Publishing assets](#publishing-assets)
@@ -26,10 +27,10 @@ Laravel package to create beautiful common views like tables using only PHP code
2627
- [Roadmap](#roadmap)
2728

2829
# 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|
3334

3435
# Installation and basic usage
3536

@@ -59,12 +60,13 @@ Add the following Blade directives in the *head* tag, and before the end *body*
5960
</html>
6061
```
6162

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+
6365
```bash
6466
php artisan view:clear
6567
```
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))
6768

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.
6870
# First table view
6971
This is a basic usage of a table view, you can [read the full table view documentation ](doc/table-view.md)
7072

@@ -75,7 +77,7 @@ php artisan make:table-view UsersTableView
7577
```
7678
With this artisan command a UsersTableView.php file will be created inside the `app/Http/Livewire` directory.
7779

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
7981
```php
8082
<?php
8183

@@ -87,10 +89,7 @@ use App\User;
8789

8890
class UsersTableView extends TableView
8991
{
90-
public function repository(): Builder
91-
{
92-
return User::query();
93-
}
92+
protected $model = User::class;
9493

9594
public function headers(): array
9695
{
@@ -128,7 +127,7 @@ You could also use the `@livewire` blade directive.
128127

129128
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.
130129

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.
132131

133132
This is the basic usage of the table view, but you can customize it with more features.
134133

@@ -177,4 +176,57 @@ Here's the plan for what's coming:
177176
- Add tooltips to actions buttons
178177
- Add a download action
179178
- 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.
221+
222+
```php
223+
/* Before */
224+
public function repository(): Builder
225+
{
226+
// You are using a single query
227+
return User::query();
228+
}
229+
230+
/** After */
231+
protected $model = User::class;
232+
```

composer.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@
2222
"phpunit/phpunit": "7.0.*|8.5.*|9.5.*",
2323
"orchestra/testbench": "4.*|5.*|6.*",
2424
"laravel/legacy-factories": "^1.1",
25-
"spatie/laravel-ray": "^1.12"
25+
"spatie/laravel-ray": "^1.12",
26+
"brianium/paratest": "^6.3",
27+
"nunomaduro/collision": "^5.3",
28+
"nunomaduro/larastan": "^0.7.6"
29+
},
30+
"scripts": {
31+
"test": "./vendor/bin/testbench package:test --parallel --no-coverage",
32+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
33+
"larastan": "./vendor/bin/phpstan analyse"
2634
},
2735
"extra": {
2836
"laravel": {

0 commit comments

Comments
 (0)