diff --git a/src/Casts/LayoutsCast.php b/src/Casts/LayoutsCast.php index 356c4ed..58cacf0 100644 --- a/src/Casts/LayoutsCast.php +++ b/src/Casts/LayoutsCast.php @@ -18,7 +18,7 @@ public function get(Model $model, string $key, mixed $value, array $attributes): $data = Json::decode($attributes[$key]); - if($data instanceof LayoutItemCollection) { + if ($data instanceof LayoutItemCollection) { return $data; } @@ -35,7 +35,7 @@ private function _map(mixed $value): LayoutItemCollection $values = []; try { - if(is_string($value) && str($value)->isJson()) { + if (is_string($value) && str($value)->isJson()) { $value = json_decode($value, true, 512, JSON_THROW_ON_ERROR); } diff --git a/src/Http/Controllers/LayoutsController.php b/src/Http/Controllers/LayoutsController.php index d2ca972..b88da5a 100644 --- a/src/Http/Controllers/LayoutsController.php +++ b/src/Http/Controllers/LayoutsController.php @@ -5,15 +5,15 @@ namespace MoonShine\Layouts\Http\Controllers; use MoonShine\Laravel\Collections\Fields; -use MoonShine\Support\Enums\PageType; -use MoonShine\Support\Enums\ToastType; use MoonShine\Laravel\Http\Controllers\MoonShineController; use MoonShine\Laravel\Http\Responses\MoonShineJsonResponse; +use MoonShine\Laravel\MoonShineRequest; use MoonShine\Layouts\Casts\LayoutItem; use MoonShine\Layouts\Collections\LayoutItemCollection; use MoonShine\Layouts\Fields\Layout; use MoonShine\Layouts\Fields\Layouts; -use MoonShine\Laravel\MoonShineRequest; +use MoonShine\Support\Enums\PageType; +use MoonShine\Support\Enums\ToastType; use Throwable; final class LayoutsController extends MoonShineController @@ -25,7 +25,7 @@ public function store(MoonShineRequest $request): MoonShineJsonResponse { $field = $this->getField($request); - if(is_null($field)) { + if (is_null($field)) { return MoonShineJsonResponse::make() ->toast('Field not found', ToastType::ERROR); } @@ -43,7 +43,7 @@ public function store(MoonShineRequest $request): MoonShineJsonResponse ->findByName($request->get('name')) ?->removeButton($field->getRemoveButton()); - if(is_null($layout)) { + if (is_null($layout)) { return MoonShineJsonResponse::make() ->toast('Layout not found', ToastType::ERROR); } @@ -52,7 +52,7 @@ public function store(MoonShineRequest $request): MoonShineJsonResponse ->collect('counts') ->get($layout->name(), 0); - if($layout->hasLimit() && $layout->limit() <= $layoutCount) { + if ($layout->hasLimit() && $layout->limit() <= $layoutCount) { return MoonShineJsonResponse::make() ->toast("Limit count {$layout->limit()}", ToastType::ERROR); } @@ -67,7 +67,7 @@ private function getField(MoonShineRequest $request): ?Layouts { $page = $request->getPage(); - if(! $resource = $request->getResource()) { + if (! $resource = $request->getResource()) { $fields = Fields::make(is_null($page->getPageType()) ? $page->components() : $page->getFields()); } else { $fields = match ($page->getPageType()) { diff --git a/tests/TestCase.php b/tests/TestCase.php index 7a1c897..dacf7a3 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -3,12 +3,11 @@ namespace MoonShine\Layouts\Tests; use Illuminate\Foundation\Testing\RefreshDatabase; -use MoonShine\Layouts\Providers\MoonShineLayoutsServiceProvider; -use MoonShine\Layouts\Tests\Fixtures\TestResource; -use MoonShine\MenuManager\MenuItem; use MoonShine\Laravel\Models\MoonshineUser; use MoonShine\Laravel\Models\MoonshineUserRole; use MoonShine\Laravel\Providers\MoonShineServiceProvider; +use MoonShine\Layouts\Providers\MoonShineLayoutsServiceProvider; +use MoonShine\Layouts\Tests\Fixtures\TestResource; use Orchestra\Testbench\TestCase as Orchestra; abstract class TestCase extends Orchestra