Compare commits

..

1 Commits

8 changed files with 112 additions and 124 deletions
-34
View File
@@ -1,34 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\TestData;
class testDataCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'data_base:test-data-command';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Тестовая команда';
/**
* Execute the console command.
*/
public function handle()
{
$testDataModel = new TestData;
$test = TestData::where('test_char', 'hellos')->get();
var_dump($test);
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace App\Dto;
class ApiResponseDto
{
public function __construct(
public readonly ?string $message = null,
// public readonly ?int $statusCode = 200,
public readonly mixed $data = null,
public readonly mixed $meta = null,
)
{
// return new self($this->message, $this->statusCode, $this->data, $this->meta);
}
// public static function success()
// {
// return new self($message, $data, $statusCode = 200);
// }
// public static function error()
// {
// return new self($message, $data, $statusCode = 400);
// }
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Services\ApiResponder;
class ApiResponderProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
$this->app->bind(ApiResponder::class, function($app){
return new ApiResponder();
});
}
/**
* Bootstrap services.
*/
public function boot(): void
{
//
}
}
-29
View File
@@ -1,29 +0,0 @@
<?php
namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
/**
* Провайдер для регистрации сервиса аутентификации
*/
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
//
];
/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
//
}
}
@@ -1,19 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}
-38
View File
@@ -1,38 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event to listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*/
public function boot(): void
{
//
}
/**
* Determine if events and listeners should be automatically discovered.
*/
public function shouldDiscoverEvents(): bool
{
return false;
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Services;
use App\Dto\ApiResponseDto;
use Illuminate\Http\JsonResponse;
class ApiResponder{
public $dto;
public function __construct(
)
{}
public function success(): JsonResponse
{
return $this->buildResponse();
}
public function error()
{
return $this->buildResponse();
}
public function setDto(ApiResponseDto $dto)
{
$this->dto = $dto;
}
// public function fromDTO(ApiResponseDto $dto)
// {
// return $dto;
// }
#Гаврилов
//СБОР СТАТИСТИКИ ПО ВЫЗЫВАЕМЫМ API ЕНДПОИНТАМ. ВНЕСТИ В TODO ПРОЕКТА
private function setStatistics()
{
}
#Гаврилов
//ДОБАВЬ ЛОГИРОВАНИЕ ОШИБОК В TRY CATCH В .LOG ФАЙЛ
private function buildResponse(): JsonResponse
{
//echo '<pre>'; var_dump((array)$this->dto); echo'</pre>';
//return (array) $this->dto;
return response()->json((array) $this->dto);
}
}
+7 -4
View File
@@ -19,14 +19,17 @@
</source> </source>
<php> <php>
<env name="APP_ENV" value="testing"/> <env name="APP_ENV" value="testing"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/> <env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/> <env name="BROADCAST_CONNECTION" value="null"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/> --> <env name="CACHE_STORE" value="array"/>
<!-- <env name="DB_DATABASE" value=":memory:"/> --> <env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="MAIL_MAILER" value="array"/> <env name="MAIL_MAILER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<env name="QUEUE_CONNECTION" value="sync"/> <env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/> <env name="SESSION_DRIVER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<env name="TELESCOPE_ENABLED" value="false"/> <env name="TELESCOPE_ENABLED" value="false"/>
<env name="NIGHTWATCH_ENABLED" value="false"/>
</php> </php>
</phpunit> </phpunit>