Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/3.x' into 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Dec 8, 2024
2 parents 210ea6d + 54c0155 commit dd870bf
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/Core/src/Traits/HasResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use MoonShine\Contracts\Core\ResourceContract;
use MoonShine\Core\Exceptions\ResourceException;
use Throwable;

/**
* @template T of ResourceContract
Expand Down Expand Up @@ -64,7 +63,7 @@ public function getResource(): ?ResourceContract

protected function validateResource(): void
{
if(! $this->hasResource()) {
if (! $this->hasResource()) {
throw ResourceException::required();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Applies/Fields/FileModelApply.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function store(File $field, UploadedFile $file): string
{
$extension = $file->extension();

if(! $field->isAllowedExtension($extension)) {
if (! $field->isAllowedExtension($extension)) {
throw FileFieldException::extensionNotAllowed($extension);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Fields/Relationships/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function resolvePreview(): string
? $this->getResource()->getFormPage()
: $this->getResource()->getDetailPage();

if(\is_null($page)) {
if (\is_null($page)) {
throw PageException::required();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Http/Controllers/HandlerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __invoke(string $resourceUri, string $handlerUri, MoonShineReque
{
$resource = $request->getResource();

if(! $resource) {
if (! $resource) {
throw ResourceException::required();
}

Expand Down
3 changes: 1 addition & 2 deletions src/Laravel/src/Http/Controllers/UpdateFieldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use MoonShine\Laravel\Http\Requests\Relations\RelationModelColumnUpdateRequest;
use MoonShine\Laravel\Http\Requests\Resources\UpdateColumnFormRequest;
use MoonShine\Laravel\Resources\CrudResource;
use MoonShine\UI\Exceptions\FieldException;
use Throwable;

class UpdateFieldController extends MoonShineController
Expand Down Expand Up @@ -47,7 +46,7 @@ public function throughRelation(RelationModelColumnUpdateRequest $request): Resp
->onlyFields()
->findByColumn($request->input('field'));

if(\is_null($field) || \is_null($resource)) {
if (\is_null($field) || \is_null($resource)) {
throw CrudResourceException::resourceOrFieldRequired();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function authorize(): bool
{
$resource = $this->getField()?->getResource();

if(\is_null($resource)) {
if (\is_null($resource)) {
throw ResourceException::notDeclared();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function getFieldItemOrFail(): Model
{
$field = $this->getField();

if(\is_null($field)) {
if (\is_null($field)) {
throw FieldException::notFound();
}

Expand Down
4 changes: 2 additions & 2 deletions src/Laravel/src/MoonShineEndpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function toPage(
$params += ['_fragment-load' => $fragment];
}

if(\is_null($page) && \is_null($resource)) {
if (\is_null($page) && \is_null($resource)) {
throw EndpointException::pageOrResourceRequired();
}

Expand All @@ -136,7 +136,7 @@ public function toPage(
: moonshine()->getPages()->findByClass($page);
}

if(\is_null($targetPage)) {
if (\is_null($targetPage)) {
throw EndpointException::pageRequired();
}

Expand Down
3 changes: 2 additions & 1 deletion src/Laravel/src/Pages/ProfilePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MoonShine\Laravel\Pages;

use LogicException;
use MoonShine\Contracts\UI\FormBuilderContract;
use MoonShine\Laravel\Http\Controllers\ProfileController;
use MoonShine\Laravel\MoonShineAuth;
Expand Down Expand Up @@ -90,7 +91,7 @@ public function getForm(): FormBuilderContract
$user = MoonShineAuth::getGuard()->user() ?? MoonShineAuth::getModel();

if (\is_null($user)) {
throw new \LogicException('Model is required');
throw new LogicException('Model is required');
}

return FormBuilder::make(action([ProfileController::class, 'store']))
Expand Down
3 changes: 1 addition & 2 deletions src/Laravel/src/Traits/Fields/WithRelatedValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Illuminate\Support\Collection;
use MoonShine\Laravel\Exceptions\ModelRelationFieldException;
use MoonShine\Support\DTOs\Select\Options;
use MoonShine\UI\Exceptions\FieldException;
use Throwable;

trait WithRelatedValues
Expand Down Expand Up @@ -54,7 +53,7 @@ public function resolveValuesQuery(): Builder
{
$relation = $this->getRelation();

if(is_null($relation)) {
if (\is_null($relation)) {
throw ModelRelationFieldException::relationRequired();
}

Expand Down
2 changes: 1 addition & 1 deletion src/UI/src/Components/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public function apply(

value($after, $values);
} catch (Throwable $e) {
if($throw) {
if ($throw) {
throw $e;
}

Expand Down
2 changes: 1 addition & 1 deletion src/UI/src/Components/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getTabs(): ComponentsContract
return tap(
$this->getComponents(),
static function (ComponentsContract $tabs): void {
if($tabs->every(static fn ($tab): bool => ! $tab instanceof Tab)) {
if ($tabs->every(static fn ($tab): bool => ! $tab instanceof Tab)) {
throw MoonShineComponentException::onlyTabAllowed();
}
}
Expand Down

0 comments on commit dd870bf

Please sign in to comment.