Skip to content

Commit 4e0e15e

Browse files
committed
Code cleaning
1 parent fb83b73 commit 4e0e15e

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

src/Composers/SidebarViewComposer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public function compose(View $view): void
1414
if (Gate::denies('read places')) {
1515
return;
1616
}
17-
$view->offsetGet('sidebar')->group(__('Content'), function (SidebarGroup $group) {
17+
$view->offsetGet('sidebar')->group(__('Content'), function (SidebarGroup $group): void {
1818
$group->id = 'content';
1919
$group->weight = 30;
20-
$group->addItem(__('Places'), function (SidebarItem $item) {
20+
$group->addItem(__('Places'), function (SidebarItem $item): void {
2121
$item->id = 'places';
2222
$item->icon = config('typicms.modules.places.sidebar.icon');
2323
$item->weight = config('typicms.modules.places.sidebar.weight');

src/Http/Controllers/AdminController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function create(): View
3232
$model = new Place();
3333

3434
return view('places::admin.create')
35-
->with(compact('model'));
35+
->with(['model' => $model]);
3636
}
3737

3838
public function edit(Place $place): View

src/Http/Controllers/ApiController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ class ApiController extends BaseApiController
1717
public function index(Request $request): LengthAwarePaginator
1818
{
1919
$query = Place::query()->selectFields();
20-
$data = QueryBuilder::for($query)
20+
21+
return QueryBuilder::for($query)
2122
->allowedSorts(['id', 'status_translated', 'title_translated'])
2223
->allowedFilters([
2324
AllowedFilter::custom('title', new FilterOr()),
2425
])
2526
->allowedIncludes(['image'])
2627
->paginate($request->integer('per_page'));
27-
28-
return $data;
2928
}
3029

3130
protected function updatePartial(Place $place, Request $request): void

src/Http/Controllers/PublicController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function index(): View
1717
->get();
1818

1919
return view('places::public.index')
20-
->with(compact('models'));
20+
->with(['models' => $models]);
2121
}
2222

2323
public function show(string $slug): View
@@ -28,6 +28,6 @@ public function show(string $slug): View
2828
->firstOrFail();
2929

3030
return view('places::public.show')
31-
->with(compact('model'));
31+
->with(['model' => $model]);
3232
}
3333
}

src/Models/Place.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Place extends Base
8080

8181
public function url(?string $locale = null): string
8282
{
83-
$locale = $locale ?: app()->getLocale();
83+
$locale ??= app()->getLocale();
8484
$route = $locale . '::place';
8585
$slug = $this->translate('slug', $locale) ?: null;
8686

src/Providers/ModuleServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function boot(): void
3737
/*
3838
* Add the page in the view.
3939
*/
40-
View::composer('places::public.*', function ($view) {
40+
View::composer('places::public.*', function ($view): void {
4141
$view->page = getPageLinkedToModule('places');
4242
});
4343
}

src/routes/places.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use TypiCMS\Modules\Core\Models\Page;
34
use Illuminate\Routing\Router;
45
use Illuminate\Support\Facades\Route;
56
use TypiCMS\Modules\Places\Http\Controllers\AdminController;
@@ -10,11 +11,11 @@
1011
/*
1112
* Front office routes
1213
*/
13-
if ($page = getPageLinkedToModule('places')) {
14+
if (($page = getPageLinkedToModule('places')) instanceof Page) {
1415
$middleware = $page->private ? ['public', 'auth'] : ['public'];
1516
foreach (locales() as $lang) {
1617
if ($page->isPublished($lang) && $path = $page->path($lang)) {
17-
Route::middleware($middleware)->prefix($path)->name($lang . '::')->group(function (Router $router) {
18+
Route::middleware($middleware)->prefix($path)->name($lang . '::')->group(function (Router $router): void {
1819
$router->get('/', [PublicController::class, 'index'])->name('index-places');
1920
$router->get('places-json', [JsonController::class, 'index'])->name('places-json');
2021
$router->get('{place}', [PublicController::class, 'show'])->name('place');
@@ -27,7 +28,7 @@
2728
/*
2829
* Admin routes
2930
*/
30-
Route::middleware('admin')->prefix('admin')->name('admin::')->group(function (Router $router) {
31+
Route::middleware('admin')->prefix('admin')->name('admin::')->group(function (Router $router): void {
3132
$router->get('places', [AdminController::class, 'index'])->name('index-places')->middleware('can:read places');
3233
$router->get('places/export', [AdminController::class, 'export'])->name('export-places')->middleware('can:read places');
3334
$router->get('places/create', [AdminController::class, 'create'])->name('create-place')->middleware('can:create places');
@@ -39,7 +40,7 @@
3940
/*
4041
* API routes
4142
*/
42-
Route::middleware(['api', 'auth:api'])->prefix('api')->group(function (Router $router) {
43+
Route::middleware(['api', 'auth:api'])->prefix('api')->group(function (Router $router): void {
4344
$router->get('places', [ApiController::class, 'index'])->middleware('can:read places');
4445
$router->patch('places/{place}', [ApiController::class, 'updatePartial'])->middleware('can:update places');
4546
$router->delete('places/{place}', [ApiController::class, 'destroy'])->middleware('can:delete places');

0 commit comments

Comments
 (0)