Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kiboko-dev committed Sep 12, 2024
1 parent 4da41ce commit 98743ae
Show file tree
Hide file tree
Showing 28 changed files with 133 additions and 220 deletions.
2 changes: 0 additions & 2 deletions app/Http/Controllers/ConnectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ConnectionController extends Controller
{
//
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@

class Controller extends BaseController
{
use AuthorizesRequests, ValidatesRequests;
use AuthorizesRequests;
use ValidatesRequests;
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/LicenseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Controllers;

use App\Http\Requests\ConnectRequest;
use app\Services\LicenseService;
use App\Http\Services\LicenseService;
use Illuminate\Http\JsonResponse;
use Knuckles\Scribe\Attributes as SA;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -16,7 +16,7 @@ class LicenseController extends Controller
#[
SA\Endpoint(
title: 'Подключиться',
description: 'Выполняется подключение. Если UUID подключения создаётся новое подключение,
description: 'Выполняется подключение. Если UUID подключения создаётся новое подключение,
если не исчерпан лимит подключений заданный в лицензии.'
),
SA\Response(content: '', status: Response::HTTP_OK, description: 'OK'),
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace App\Http\Controllers;

use App\Http\Requests\GetSettingsRequest;
use app\Services\SettingsService;
use App\Http\Services\SettingsService;
use Illuminate\Http\JsonResponse;
use Knuckles\Scribe\Attributes as SA;
use Symfony\Component\HttpFoundation\Response;


#[
SA\Group('Настройки')
]
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/SettingValueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class SettingValueController extends Controller
{
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace App\Http\Repositories;

use App\Exceptions\IncorrectConnectionException;
use App\Models\Connection;

Expand All @@ -10,7 +12,7 @@ public function getCountByLicense(string $license): int
return Connection::whereLicense($license)->count();
}

public function create(string $license, string $ip)
public function create(string $license, ?string $ip = '127.0.0.1')
{
return Connection::create([
'license' => $license,
Expand All @@ -34,4 +36,4 @@ public function check(string $uuid, string $ip): void
throw new IncorrectConnectionException();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace App\Http\Repositories;

use App\Models\License;

class LicenseRepository
Expand All @@ -8,4 +10,4 @@ public function getAvailableCountForLicense(string $license): ?int
{
return License::find($license)->connections;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace App\Http\Repositories;

use App\Exceptions\NoDefaultSettingsException;
use App\Models\Setting;
use App\Models\SettingValue;
Expand All @@ -11,7 +13,7 @@ class SettingsRepository
*/
public function getDefaultSettings(): ?array
{
$settings = Setting::all()->pluck('default_value', 'key')->toArray();
$settings = Setting::all()->pluck('default_value', 'key')->toArray();

if (count($settings) === 0) {
throw new NoDefaultSettingsException();
Expand All @@ -24,4 +26,4 @@ public function getByConnection(string $connection): ?array
{
return SettingValue::whereConnectionUuid($connection)->pluck('value', 'key')->toArray();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace app\Services;
namespace App\Http\Services;

use App\Exceptions\ConnectionLimitException;
use App\Exceptions\IncorrectConnectionException;
use ConnectionRepository;
use LicenseRepository;
use App\Http\Repositories\ConnectionRepository;
use App\Http\Repositories\LicenseRepository;

class LicenseService
{
Expand Down Expand Up @@ -56,4 +56,4 @@ public function checkConnectionsLimit(string $license): void
throw new ConnectionLimitException();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace app\Services;
namespace App\Http\Services;

use SettingsRepository;
use App\Http\Repositories\SettingsRepository;

class SettingsService
{
Expand All @@ -20,4 +20,4 @@ public function getByConnectionUuid(string $connectionUuid): array

return $settings;
}
}
}
3 changes: 2 additions & 1 deletion app/Models/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

class Connection extends Model
{
use SoftDeletes, HasUuids;
use SoftDeletes;
use HasUuids;

protected $table = 'connections';

Expand Down
3 changes: 2 additions & 1 deletion app/Models/License.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

class License extends Model
{
use SoftDeletes, HasUuids;
use SoftDeletes;
use HasUuids;

protected $table = 'licenses';

Expand Down
1 change: 0 additions & 1 deletion app/Models/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
Expand Down
4 changes: 3 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
use HasApiTokens;
use HasFactory;
use Notifiable;

/**
* The attributes that are mass assignable.
Expand Down
6 changes: 3 additions & 3 deletions app/MoonShine/Pages/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function title(): string
* @return list<MoonShineComponent>
*/
public function components(): array
{
return [];
}
{
return [];
}
}
10 changes: 3 additions & 7 deletions app/MoonShine/Resources/LicenseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@

use Illuminate\Database\Eloquent\Model;
use App\Models\License;

use MoonShine\Fields\Number;
use MoonShine\Fields\Text;
use MoonShine\Resources\ModelResource;
use MoonShine\Decorations\Block;
use MoonShine\Fields\ID;
use MoonShine\Fields\Field;
use MoonShine\Components\MoonShineComponent;

class LicenseResource extends ModelResource
{
Expand All @@ -25,9 +21,9 @@ public function fields(): array
{
return [
Block::make([
Text::make('Лицензия','id')->readonly()->sortable(),
Text::make('Организация','client_name')->sortable(),
Number::make('МАХ подключений','connections')
Text::make('Лицензия', 'id')->readonly()->sortable(),
Text::make('Организация', 'client_name')->sortable(),
Number::make('МАХ подключений', 'connections')
]),
];
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"require-dev": {
"fakerphp/faker": "^1.9.1",
"knuckleswtf/scribe": "^4.37",
"laravel/pint": "^1.0",
"laravel/pint": "^1.17",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
Expand Down
Loading

0 comments on commit 98743ae

Please sign in to comment.