fix: php-cs-fixed fix

This commit is contained in:
b1ek 2024-08-30 17:37:24 +10:00
parent c320d10e08
commit 9922ebbc39
Signed by: blek
GPG Key ID: 14546221E3595D0C
22 changed files with 42 additions and 37 deletions

View File

@ -7,4 +7,4 @@ class Filter
public FilterTypeEnum $type; public FilterTypeEnum $type;
public string $column; public string $column;
public mixed $filter; public mixed $filter;
} }

View File

@ -7,4 +7,4 @@ enum FilterTypeEnum: string
case Is = 'is'; case Is = 'is';
case Not = 'not'; case Not = 'not';
case Like = 'like'; case Like = 'like';
} }

View File

@ -11,7 +11,6 @@ use JsonMapper;
class Filters class Filters
{ {
/** /**
* @var Filter[] * @var Filter[]
*/ */
@ -30,7 +29,7 @@ class Filters
if (is_array($data)) { if (is_array($data)) {
$data = json_decode(json_encode($data), false); $data = json_decode(json_encode($data), false);
} }
$data->filters ??= []; $data->filters ??= [];
$data->orders ??= []; $data->orders ??= [];
$data->pagination ??= null; $data->pagination ??= null;
@ -63,7 +62,7 @@ class Filters
} }
if (!is_null($this->pagination)) { if (!is_null($this->pagination)) {
$builder->paginate($this->pagination->size , ['*'], 'page', $this->pagination->page); $builder->paginate($this->pagination->size, ['*'], 'page', $this->pagination->page);
} }
} }
} }

View File

@ -6,4 +6,4 @@ enum OrderTypeEnum: string
{ {
case Asc = 'asc'; case Asc = 'asc';
case Desc = 'desc'; case Desc = 'desc';
} }

View File

@ -6,4 +6,4 @@ class Pagination
{ {
public int $size; public int $size;
public int $page; public int $page;
} }

View File

@ -1,6 +1,7 @@
<?php <?php
namespace App; namespace App;
use App\Models\History; use App\Models\History;
class HistoryObserver class HistoryObserver

View File

@ -11,8 +11,9 @@ class PrivateUserController extends Controller
{ {
public function __construct( public function __construct(
private UserService $userService private UserService $userService
) { } ) {
}
public function list(AuthorizedRequest $request) public function list(AuthorizedRequest $request)
{ {
return $this->userService->listAll(); return $this->userService->listAll();

View File

@ -10,7 +10,8 @@ class PublicUserController extends Controller
{ {
public function __construct( public function __construct(
private UserService $userService private UserService $userService
) { } ) {
}
public function register(RegisterRequest $request) public function register(RegisterRequest $request)
{ {

View File

@ -25,7 +25,7 @@ class LoginRequest extends RestRequest
{ {
return [ return [
'email' => ['required', 'email'], 'email' => ['required', 'email'],
'password' => ['required', Password::min(1)->rules([ new ZxcvbnRule ])], 'password' => ['required', Password::min(1)->rules([ new ZxcvbnRule() ])],
]; ];
} }
} }

View File

@ -30,7 +30,7 @@ class RegisterRequest extends RestRequest
'middle_name' => ['required', 'string'], 'middle_name' => ['required', 'string'],
'email' => ['required', 'email'], 'email' => ['required', 'email'],
'phone' => ['required', 'regex:' . User::PHONE_REGEX ], 'phone' => ['required', 'regex:' . User::PHONE_REGEX ],
'password' => ['required', Password::min(1)->rules([ new ZxcvbnRule ])], 'password' => ['required', Password::min(1)->rules([ new ZxcvbnRule() ])],
]; ];
} }
} }

View File

@ -9,7 +9,6 @@ use Illuminate\Validation\Rules\Password;
class UserEditRequest extends AuthorizedRequest class UserEditRequest extends AuthorizedRequest
{ {
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
@ -24,7 +23,7 @@ class UserEditRequest extends AuthorizedRequest
'user.email' => [ 'email' ], 'user.email' => [ 'email' ],
'user.phone' => [ 'string', 'regex:' . User::PHONE_REGEX ], 'user.phone' => [ 'string', 'regex:' . User::PHONE_REGEX ],
'user' => 'required', 'user' => 'required',
'password' => [ Password::min(1)->rules([ new ZxcvbnRule ]) ], 'password' => [ Password::min(1)->rules([ new ZxcvbnRule() ]) ],
'user.email_verified_at' => 'prohibited', 'user.email_verified_at' => 'prohibited',
'user.created_at' => 'prohibited', 'user.created_at' => 'prohibited',

View File

@ -9,7 +9,8 @@ use Illuminate\Database\Eloquent\Model;
class History extends Model class History extends Model
{ {
use HasFactory, UuidId; use HasFactory;
use UuidId;
protected $fillable = [ protected $fillable = [
'model_id', 'model_id',

View File

@ -11,7 +11,10 @@ use Illuminate\Notifications\Notifiable;
class User extends Authenticatable class User extends Authenticatable
{ {
use HasFactory, Notifiable, UuidId, HasHistory; use HasFactory;
use Notifiable;
use UuidId;
use HasHistory;
public const PHONE_REGEX = '/^\+\d+$/'; public const PHONE_REGEX = '/^\+\d+$/';

View File

@ -94,7 +94,7 @@ class UserService
$users = User::whereIn('id', $ids)->get(); $users = User::whereIn('id', $ids)->get();
if ($users->count() != count($ids)) { if ($users->count() != count($ids)) {
$existingIds = $users->map( $existingIds = $users->map(
function($model) { function ($model) {
return $model->id; return $model->id;
} }
)->toArray(); )->toArray();
@ -102,4 +102,4 @@ class UserService
} }
return null; return null;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
namespace App\Services; namespace App\Services;
use App\Models\User; use App\Models\User;
class UserTrashService class UserTrashService
@ -10,7 +11,7 @@ class UserTrashService
) { ) {
} }
public function moveUsersToTrash(array $ids): bool | array public function moveUsersToTrash(array $ids): bool | array
{ {
$unexisting = $this->userService->getUnexistingIds($ids); $unexisting = $this->userService->getUnexistingIds($ids);

View File

@ -1,20 +1,24 @@
<?php <?php
namespace App; namespace App;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
trait UuidId trait UuidId
{ {
protected static function boot() { protected static function boot()
{
parent::boot(); parent::boot();
static::creating(function ($model) { static::creating(function ($model) {
$model->id = Uuid::uuid6()->toString(); $model->id = Uuid::uuid6()->toString();
}); });
} }
public function getIncrementing(): bool { public function getIncrementing(): bool
{
return false; return false;
} }
public function getKeyType(): string { public function getKeyType(): string
{
return 'string'; return 'string';
} }
} }

View File

@ -5,8 +5,7 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder; use Illuminate\Database\Schema\Builder;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class () extends Migration {
{
/** /**
* Run the migrations. * Run the migrations.
*/ */

View File

@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class () extends Migration {
{
/** /**
* Run the migrations. * Run the migrations.
*/ */

View File

@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class () extends Migration {
{
/** /**
* Run the migrations. * Run the migrations.
*/ */

View File

@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class () extends Migration {
{
/** /**
* Run the migrations. * Run the migrations.
*/ */

View File

@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class () extends Migration {
{
/** /**
* Run the migrations. * Run the migrations.
*/ */

View File

@ -5,12 +5,12 @@ use App\Http\Controllers\PublicUserController;
use App\Http\Controllers\TrashUserController; use App\Http\Controllers\TrashUserController;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
Route::get('/', function() { Route::get('/', function () {
return view('welcome'); return view('welcome');
}); });
Route::prefix('/api')->group(function() { Route::prefix('/api')->group(function () {
Route::controller(PublicUserController::class)->prefix('/users')->group(function() { Route::controller(PublicUserController::class)->prefix('/users')->group(function () {
Route::put('/register', 'register'); Route::put('/register', 'register');
Route::post('/login', 'login'); Route::post('/login', 'login');
Route::post('/reset', 'reset'); Route::post('/reset', 'reset');
@ -28,6 +28,6 @@ Route::prefix('/api')->group(function() {
}); });
}); });
Route::get('/session', function() { Route::get('/session', function () {
exit(print_r(session()->all(), true)); exit(print_r(session()->all(), true));
}); });