Skip to content

Commit ddb6ddf

Browse files
committed
Laravel 12
1 parent 7661e41 commit ddb6ddf

File tree

8 files changed

+139
-18
lines changed

8 files changed

+139
-18
lines changed

.github/workflows/main.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Novius CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
lint-php:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: '8.2'
18+
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
- name: Cache composer dependencies
23+
uses: actions/cache@v3
24+
with:
25+
path: vendor
26+
key: composer-${{ hashFiles('composer.lock') }}
27+
28+
- name: Add Nova key
29+
run: composer config http-basic.nova.laravel.com $LARAVEL_NOVA_USERNAME $LARAVEL_NOVA_LICENSE_KEY
30+
env:
31+
LARAVEL_NOVA_USERNAME: ${{ secrets.LARAVEL_NOVA_USERNAME }}
32+
LARAVEL_NOVA_LICENSE_KEY: ${{ secrets.LARAVEL_NOVA_LICENSE_KEY }}
33+
34+
- name: Install Dependencies
35+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
36+
37+
- name: Lint PHP code via Laravel Pint
38+
run: composer run-script lint
39+
40+
phpstan:
41+
42+
runs-on: ubuntu-latest
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
operating-system: ['ubuntu-latest']
47+
php-versions: ['8.2', '8.3', '8.4']
48+
laravel: [ 11.*, 12.* ]
49+
nova: [ 4.*, 5.* ]
50+
dependency-version: [ prefer-stable ]
51+
include:
52+
- laravel: 12.*
53+
carbon: 3.*
54+
- laravel: 11.*
55+
carbon: 2.*
56+
exclude:
57+
- laravel: 12.*
58+
nova: 4.*
59+
60+
name: phpstan - P${{ matrix.php-versions }} - L${{ matrix.laravel }} - N${{ matrix.nova }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
61+
62+
steps:
63+
- uses: shivammathur/setup-php@v2
64+
with:
65+
php-version: ${{ matrix.php-versions }}
66+
67+
- name: Checkout code
68+
uses: actions/checkout@v3
69+
70+
- name: Cache composer dependencies
71+
uses: actions/cache@v3
72+
with:
73+
path: vendor
74+
key: composer-${{ hashFiles('composer.lock') }}
75+
76+
- name: Add Nova key
77+
run: composer config http-basic.nova.laravel.com $LARAVEL_NOVA_USERNAME $LARAVEL_NOVA_LICENSE_KEY
78+
env:
79+
LARAVEL_NOVA_USERNAME: ${{ secrets.LARAVEL_NOVA_USERNAME }}
80+
LARAVEL_NOVA_LICENSE_KEY: ${{ secrets.LARAVEL_NOVA_LICENSE_KEY }}
81+
82+
- name: Install Dependencies
83+
run: |
84+
composer require "laravel/framework:${{ matrix.laravel }}" "nesbot/carbon:${{ matrix.carbon }}" "laravel/nova:${{ matrix.nova }}" --no-interaction --no-update
85+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
86+
87+
- name: PHPStan Static Analysis
88+
run: composer run-script phpstan

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
],
1717
"require": {
1818
"php": ">=8.2",
19-
"illuminate/support": "^10.0|^11.0",
20-
"laravel/nova": "^4.0|^5.0",
19+
"laravel/framework": "^10.0 | ^11.0 | ^12.0",
20+
"laravel/nova": "^4.0 | ^5.0",
2121
"novius/laravel-linkable": "^1.0",
2222
"novius/laravel-json-casted": "^1.0.0",
2323
"novius/laravel-meta": "^1.0",
@@ -27,6 +27,7 @@
2727
"spatie/laravel-sluggable": "^3.4"
2828
},
2929
"require-dev": {
30+
"larastan/larastan": "^2.0 | ^3.0",
3031
"laravel/pint": "^1.7"
3132
},
3233
"autoload": {
@@ -47,6 +48,9 @@
4748
],
4849
"lint": [
4950
"@composer fmt -- --test"
51+
],
52+
"phpstan": [
53+
"./vendor/bin/phpstan analyse --memory-limit=1G"
5054
]
5155
},
5256
"repositories": [

phpstan.dist.neon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
includes:
2+
- vendor/larastan/larastan/extension.neon
3+
- vendor/nesbot/carbon/extension.neon
4+
5+
parameters:
6+
paths:
7+
- src
8+
- config
9+
10+
bootstrapFiles:
11+
- phpstan/bootstrap.php
12+
13+
# Level 10 is the highest level
14+
level: 5
15+
16+
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
17+
editorUrlTitle: '%%file%%:%%line%%'

phpstan/bootstrap.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
use Illuminate\Foundation\Application;
4+
5+
Application::configure(basePath: dirname(__DIR__));

src/Console/FrontControllerCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class FrontControllerCommand extends GeneratorCommand
2727
*/
2828
protected $type = 'Controller';
2929

30+
/**
31+
* @phpstan-ignore method.childReturnType
32+
*/
3033
public function handle(): void
3134
{
3235
if (parent::handle() !== false) {

src/LaravelNovaPageManagerServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public function boot(): void
5252
}
5353

5454
$resourceId = $parameters[1] ?? null;
55-
$query = Page::where('locale', $parameters[0])
55+
$query = Page::query()
56+
->where('locale', $parameters[0])
5657
->where('slug', $value);
5758
if ($resourceId) {
5859
$query->where('id', '<>', $resourceId);

src/Models/Page.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Novius\LaravelNovaPageManager\Models;
44

5-
use Eloquent;
65
use Illuminate\Database\Eloquent\Builder;
76
use Illuminate\Database\Eloquent\Casts\Attribute;
87
use Illuminate\Database\Eloquent\Model;
@@ -28,20 +27,20 @@
2827
/**
2928
* Class Page
3029
*
31-
* @property string title
32-
* @property string slug
33-
* @property string locale
34-
* @property string template
35-
* @property int parent_id
36-
* @property int locale_parent_id
30+
* @property string $title
31+
* @property string $slug
32+
* @property string $locale
33+
* @property string $template
34+
* @property int $parent_id
35+
* @property int $locale_parent_id
3736
* @property PublicationStatus $publication_status
3837
* @property Carbon|null $published_first_at
3938
* @property Carbon|null $published_at
4039
* @property Carbon|null $expired_at
41-
* @property string preview_token
42-
* @property array extras
43-
* @property Carbon created_at
44-
* @property Carbon updated_at
40+
* @property string $preview_token
41+
* @property array $extras
42+
* @property Carbon $created_at
43+
* @property Carbon $updated_at
4544
* @property-read string|null $seo_robots
4645
* @property-read string|null $seo_title
4746
* @property-read string|null $seo_description
@@ -63,7 +62,7 @@
6362
* @method static Builder|Page query()
6463
* @method static Builder|Page withLocale(?string $locale)
6564
*
66-
* @mixin Eloquent
65+
* @mixin Model
6766
*/
6867
class Page extends Model
6968
{

src/Resources/Page.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Novius\LaravelMeta\Traits\NovaResourceHasMeta;
1818
use Novius\LaravelNovaFieldPreview\Nova\Fields\OpenPreview;
1919
use Novius\LaravelNovaPageManager\Helpers\TemplatesHelper;
20+
use Novius\LaravelNovaPageManager\Models\Page as PageModel;
2021
use Novius\LaravelNovaPublishable\Nova\Fields\ExpiredAt;
2122
use Novius\LaravelNovaPublishable\Nova\Fields\PublicationBadge;
2223
use Novius\LaravelNovaPublishable\Nova\Fields\PublicationStatus as PublicationStatusField;
@@ -28,6 +29,9 @@
2829
use Novius\LaravelNovaTranslatable\Nova\Fields\Translations;
2930
use Novius\LaravelNovaTranslatable\Nova\Filters\LocaleFilter;
3031

32+
/**
33+
* @extends Resource<PageModel>
34+
*/
3135
class Page extends Resource
3236
{
3337
use NovaResourceHasMeta;
@@ -37,11 +41,11 @@ class Page extends Resource
3741
/**
3842
* The model the resource corresponds to.
3943
*
40-
* @var class-string<\Novius\LaravelNovaPageManager\Models\Page>
44+
* @var class-string<PageModel>
4145
*/
42-
public static string $model = \Novius\LaravelNovaPageManager\Models\Page::class;
46+
public static string $model = PageModel::class;
4347

44-
/** @var \Novius\LaravelNovaPageManager\Models\Page|null */
48+
/** @var PageModel|null */
4549
public $resource;
4650

4751
/**

0 commit comments

Comments
 (0)