Skip to content

Commit bbaf852

Browse files
committed
Code cleaning
1 parent 420d32c commit bbaf852

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
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 things')) {
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(__('Things'), function (SidebarItem $item) {
20+
$group->addItem(__('Things'), function (SidebarItem $item): void {
2121
$item->id = 'things';
2222
$item->icon = config('typicms.modules.things.sidebar.icon');
2323
$item->weight = config('typicms.modules.things.sidebar.weight');

src/Http/Controllers/AdminController.php

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

3333
return view('things::admin.create')
34-
->with(compact('model'));
34+
->with(['model' => $model]);
3535
}
3636

3737
public function edit(Thing $thing): 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 = Thing::query()->selectFields();
20-
$data = QueryBuilder::for($query)
20+
21+
return QueryBuilder::for($query)
2122
->allowedSorts(['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(Thing $thing, 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('things::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('things::public.show')
31-
->with(compact('model'));
31+
->with(['model' => $model]);
3232
}
3333
}

src/Providers/ModuleServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function boot(): void
3232
/*
3333
* Add the page in the view.
3434
*/
35-
View::composer('things::public.*', function ($view) {
35+
View::composer('things::public.*', function ($view): void {
3636
$view->page = getPageLinkedToModule('things');
3737
});
3838
}

src/routes/things.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\Things\Http\Controllers\AdminController;
@@ -9,11 +10,11 @@
910
/*
1011
* Front office routes
1112
*/
12-
if ($page = getPageLinkedToModule('things')) {
13+
if (($page = getPageLinkedToModule('things')) instanceof Page) {
1314
$middleware = $page->private ? ['public', 'auth'] : ['public'];
1415
foreach (locales() as $lang) {
1516
if ($page->isPublished($lang) && $path = $page->path($lang)) {
16-
Route::middleware($middleware)->prefix($path)->name($lang . '::')->group(function (Router $router) {
17+
Route::middleware($middleware)->prefix($path)->name($lang . '::')->group(function (Router $router): void {
1718
$router->get('/', [PublicController::class, 'index'])->name('index-things');
1819
$router->get('{slug}', [PublicController::class, 'show'])->name('thing');
1920
});
@@ -24,7 +25,7 @@
2425
/*
2526
* Admin routes
2627
*/
27-
Route::middleware('admin')->prefix('admin')->name('admin::')->group(function (Router $router) {
28+
Route::middleware('admin')->prefix('admin')->name('admin::')->group(function (Router $router): void {
2829
$router->get('things', [AdminController::class, 'index'])->name('index-things')->middleware('can:read things');
2930
$router->get('things/export', [AdminController::class, 'export'])->name('export-things')->middleware('can:read things');
3031
$router->get('things/create', [AdminController::class, 'create'])->name('create-thing')->middleware('can:create things');
@@ -36,7 +37,7 @@
3637
/*
3738
* API routes
3839
*/
39-
Route::middleware(['api', 'auth:api'])->prefix('api')->group(function (Router $router) {
40+
Route::middleware(['api', 'auth:api'])->prefix('api')->group(function (Router $router): void {
4041
$router->get('things', [ApiController::class, 'index'])->middleware('can:read things');
4142
$router->patch('things/{thing}', [ApiController::class, 'updatePartial'])->middleware('can:update things');
4243
$router->post('things/{thing}/duplicate', [ApiController::class, 'duplicate'])->middleware('can:create things');

0 commit comments

Comments
 (0)