Skip to content

Commit

Permalink
Merge branch '9.4' into 9.5
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Jul 13, 2023
2 parents 3778065 + 96e064b commit cece359
Show file tree
Hide file tree
Showing 24 changed files with 240 additions and 142 deletions.
1 change: 0 additions & 1 deletion .github/workflows/larastan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Larastan
on:
push:
branches:
- "8.*"
- "9.*"
- "10.*"
- "master"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, intl, fileinfo
coverage: none

Expand Down
71 changes: 0 additions & 71 deletions .github/workflows/update-assets.yml

This file was deleted.

2 changes: 2 additions & 0 deletions app/Nova/Actions/AddComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public function fields(NovaRequest $request): array
->dependsOn('anonymous', function (BelongsTo $field, NovaRequest $request, FormData $formData) {
if ($formData->boolean('anonymous') === false) {
$field->show()->rules('required');
} else {
$field->hide()->setValue(null);
}
}),

Expand Down
4 changes: 2 additions & 2 deletions app/Nova/Actions/CreateUserProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ public function fields(NovaRequest $request): array
->dependsOn(['github'], function (Timezone $field, NovaRequest $request, FormData $formData) {
switch ($formData->github) {
case 'crynobone':
$field->default('Asia/Kuala_Lumpur');
$field->setValue('Asia/Kuala_Lumpur');
break;
default:
$field->default('UTC');
$field->setValue('UTC');
}
})->default('UTC'),
];
Expand Down
13 changes: 13 additions & 0 deletions app/Nova/Actions/SendNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Collection;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\ActionFields;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\FormData;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
Expand Down Expand Up @@ -37,6 +38,10 @@ public function handle(ActionFields $fields, Collection $models): mixed

if (! empty($fields->action_url) && ! empty($fields->action_text)) {
$notification->action($fields->action_text, NovaURL::remote($fields->action_url));

if ($fields->openInNewTab === true) {
$notification->openInNewTab();
}
}

$models->each->notify($notification);
Expand Down Expand Up @@ -102,6 +107,14 @@ public function fields(NovaRequest $request): array
}
}),

Boolean::make('Open in New Tab', 'openInNewTab')
->default(false)
->dependsOn(['action_url', 'action_text'], function (Boolean $field, NovaRequest $request, FormData $formData) {
if (empty($formData->action_url) || empty($formData->action_text)) {
$field->hide();
}
}),

Select::make('Icon')
->rules(['required'])
->options([])
Expand Down
5 changes: 3 additions & 2 deletions app/Nova/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ public function fields(NovaRequest $request): array
return [
ID::make()->sortable(),

Repeater::make('Invoice Items', 'items', InvoiceItem::class)
Repeater::make('Invoice Items', 'items')
->repeatables([
InvoiceItemRepeater::make(),
])->asHasMany(),
])->asHasMany(InvoiceItem::class)
->uniqueField('id'),

HasMany::make('InvoiceItem', 'items'),
];
Expand Down
24 changes: 22 additions & 2 deletions app/Nova/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Laravel\Nova\Fields\Image;
use Laravel\Nova\Fields\MorphTo;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\VaporImage;
use Laravel\Nova\Http\Requests\NovaRequest;

/**
Expand Down Expand Up @@ -54,13 +55,32 @@ public function fields(NovaRequest $request): array
People::class,
])->nullable(),

Image::make('URL')
->storeOriginalName('filename'),
$this->imageField($request)->storeOriginalName('filename'),

Text::make('Filename')->onlyOnDetail(),
];
}

/**
* Get the image field for the user.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return \Laravel\Nova\Fields\VaporImage|\Laravel\Nova\Fields\Image
*/
protected function imageField(NovaRequest $request)
{
$storage = $request->user()->settings['storage'] ?? 'local';

if ($storage === 'vapor') {
return VaporImage::make('URL')
->help('Using cloud storage');
}

return Image::make('URL')
->disk($storage === 's3' ? 's3' : config('nova.storage_disk'))
->help('Using local storage');
}

/**
* Get the cards available for the request.
*
Expand Down
33 changes: 24 additions & 9 deletions app/Nova/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public function fields(NovaRequest $request): array

if (Str::startsWith($title, 'Space Pilgrim:')) {
$field->setValue(1);
} elseif (Str::startsWith($title, 'Nova:')) {
$field->setValue(null);
}
})
->reorderAssociatables(uses_with_reordering())
Expand All @@ -85,7 +87,7 @@ public function fields(NovaRequest $request): array
Text::make('Title', 'title')->rules('required')->sortable(),

$this->editorField($request, 'Excerpt', 'excerpt')->nullable(),
$this->editorField($request, 'Body', 'body')->rules('required')->stacked(),
$this->editorField($request, 'Body', 'body')->rules('required')->stacked()->fullWidth(),

File::make('Attachment')
->nullable()
Expand All @@ -106,20 +108,33 @@ public function fields(NovaRequest $request): array
})->searchable(uses_searchable())
->showCreateRelationButton(uses_inline_create()),

new Heading('Social Data'),
Heading::make('Social Data')
->dependsOnCreating('title', function (Heading $field, NovaRequest $request, FormData $formData) {
$title = $formData->title ?? '';

if (Str::startsWith($title, 'Space Pilgrim:')) {
$field->hide();
}
}),

KeyValue::make('Meta')
->dependsOnCreating('title', function (KeyValue $field, NovaRequest $request, FormData $formData) {
->dependsOnCreating(['title', 'user'], function (KeyValue $field, NovaRequest $request, FormData $formData) {
$title = $formData->title ?? '';

$defaults = [];

if (Str::startsWith($title, 'Space Pilgrim:')) {
$field->default([
'Series' => 'Space Pilgrim',
]);
$defaults['Series'] = 'Space Pilgrim';
} elseif (Str::startsWith($title, 'Nova:')) {
$field->default([
'Series' => 'Laravel Nova',
]);
$defaults['Series'] = 'Laravel Nova';
}

if (is_null($formData->user)) {
$defaults['Author'] = 'Anonymous';
}

if (! empty($defaults)) {
$field->default($defaults);
}
})->nullable(),
];
Expand Down
18 changes: 9 additions & 9 deletions app/Nova/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ public function fields(NovaRequest $request): array
MultiSelect::make('Interests')->options(function () {
return $this->interestsOptions()->all();
})->filterable()
->dependsOn('github_url', function (MultiSelect $field, NovaRequest $request, FormData $formData) {
if ($formData->github_url === 'https://github.com/taylorotwell') {
$field->options(function () {
return $this->interestsOptions()->reject(function ($value, $key) {
return $key === 'hack';
})->all();
});
}
}),
->dependsOn('github_url', function (MultiSelect $field, NovaRequest $request, FormData $formData) {
if ($formData->github_url === 'https://github.com/taylorotwell') {
$field->options(function () {
return $this->interestsOptions()->reject(function ($value, $key) {
return $key === 'hack';
})->all();
});
}
}),

HasOne::make('Passport'),

Expand Down
2 changes: 1 addition & 1 deletion app/Nova/Repeater/InvoiceItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class InvoiceItem extends Repeatable
public function fields(NovaRequest $request)
{
return [
ID::make(),
ID::hidden(),

Number::make('Quantity')->rules('numeric'),
Text::make('Description')->rules('string'),
Expand Down
3 changes: 2 additions & 1 deletion app/Nova/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public function fields(NovaRequest $request): array
->default(true)
->filterable()
->showOnPreview()
->hideFromIndex(),
->hideFromIndex()
->showWhenPeeking(),

BooleanGroup::make('Permissions')->options([
'create' => 'Create',
Expand Down
9 changes: 8 additions & 1 deletion app/Providers/NovaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,14 @@ public function register()
Nova::notificationPollingInterval((int) CarbonInterval::days(1)->totalSeconds);

Nova::serving(function (ServingNova $event) {
if (! is_null($pagination = data_get($event->request->user(), 'settings.pagination'))) {
/** @var \App\Models\User|null $user */
$user = $event->request->user();

// if (! is_null($user) && $user->getKey() === 4) {
// Nova::initialPath('/dashboards/posts-dashboard');
// }

if (! is_null($pagination = data_get($user, 'settings.pagination'))) {
config(['nova.pagination' => $pagination]);
}
});
Expand Down
2 changes: 2 additions & 0 deletions lang/vendor/nova/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Are you sure you want to force delete the selected resources?": "Are you sure you want to force delete the selected resources?",
"Are you sure you want to restore this resource?": "Are you sure you want to restore this resource?",
"Are you sure you want to restore the selected resources?": "Are you sure you want to restore the selected resources?",
"Are you sure you want to remove this item?": "Are you sure you want to remove this item?",
"No :resource matched the given criteria.": "No :resource matched the given criteria.",
"Failed to load :resource!": "Failed to load :resource!",
"Another user has updated this resource since this page was loaded. Please refresh the page and try again.": "Another user has updated this resource since this page was loaded. Please refresh the page and try again.",
Expand Down Expand Up @@ -396,6 +397,7 @@
"New :resource": "New :resource",
"Edit :resource": "Edit :resource",
"Update :resource": "Update :resource",
"Add :resource": "Add :resource",
"Start Polling": "Start Polling",
"Stop Polling": "Stop Polling",
"Choose :field": "Choose :field",
Expand Down
2 changes: 1 addition & 1 deletion nova-components/CustomField/dist/js/field.js

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions nova-components/CustomField/dist/js/field.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
* @license MIT */

/*!
* vuex v4.0.2
* (c) 2021 Evan You
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/

/*!
* vuex v4.1.0
* (c) 2022 Evan You
* @license MIT
*/

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
17 changes: 16 additions & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,30 @@ parameters:
path: app/Nova/Dashboards/Metrics/NewPosts.php

-
message: "#^Access to an undefined property object\\:\\:\\$type\\.$#"
message: "#^Access to an undefined property Illuminate\\\\Database\\\\Eloquent\\\\Model\\|Laravel\\\\Nova\\\\Support\\\\Fluent\\:\\:\\$type\\.$#"
count: 1
path: app/Nova/Fields/BookPurchase.php

-
message: "#^Parameter \\#1 \\$repeatables of method Laravel\\\\Nova\\\\Fields\\\\Repeater\\:\\:repeatables\\(\\) expects array\\<int, string\\>, array\\<int, App\\\\Nova\\\\Repeater\\\\InvoiceItem\\> given\\.$#"
count: 1
path: app/Nova/Invoice.php

-
message: "#^Parameter \\#1 \\$callback of method Laravel\\\\Nova\\\\Element\\:\\:canSee\\(\\) expects Closure\\(Illuminate\\\\Http\\\\Request\\)\\: bool, Closure\\(Illuminate\\\\Http\\\\Request\\)\\: \\(bool\\|null\\) given\\.$#"
count: 1
path: app/Nova/Post.php

-
message: "#^Access to an undefined property Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:\\$github_url\\.$#"
count: 1
path: app/Nova/Profile.php

-
message: "#^Call to an undefined method Laravel\\\\Nova\\\\Actions\\\\Action\\|Laravel\\\\Nova\\\\Actions\\\\ActionResponse\\:\\:canRun\\(\\)\\.$#"
count: 1
path: app/Nova/Profile.php

-
message: "#^If condition is always true\\.$#"
count: 1
Expand Down
Loading

0 comments on commit cece359

Please sign in to comment.