initial commit
This commit is contained in:
57
app/Providers/AppServiceProvider.php
Normal file
57
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Services\ProcessImportMonitor\DatabaseProcessImportMonitor;
|
||||
use App\Services\ProcessImportMonitor\ProcessImportMonitor;
|
||||
use App\Services\SearchProvider\DatabaseSearchProvider;
|
||||
use App\Services\SearchProvider\SearchProvider;
|
||||
use App\Services\Storage\ContactStorageProvider;
|
||||
use App\Services\Storage\DatabaseContactStorageProvider;
|
||||
use App\Services\Storage\DatabaseImportStorageProvider;
|
||||
use App\Services\Storage\ProcessImportStorageProvider;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->bind(
|
||||
SearchProvider::class,
|
||||
DatabaseSearchProvider::class,
|
||||
);
|
||||
$this->app->bind(
|
||||
ContactStorageProvider::class,
|
||||
DatabaseContactStorageProvider::class
|
||||
);
|
||||
$this->app->bind(
|
||||
ProcessImportStorageProvider::class,
|
||||
DatabaseImportStorageProvider::class,
|
||||
);
|
||||
$this->app->bind(
|
||||
ProcessImportMonitor::class,
|
||||
DatabaseProcessImportMonitor::class,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
View::composer('contacts.*', function (\Illuminate\View\View $view): void {
|
||||
$q = request()->query('q');
|
||||
$searchQuery = is_string($q) ? $q : null;
|
||||
$searchQueryParams = $searchQuery !== null && $searchQuery !== '' ? ['q' => $searchQuery] : [];
|
||||
|
||||
$view->with('searchQuery', $searchQuery);
|
||||
$view->with('searchQueryParams', $searchQueryParams);
|
||||
});
|
||||
}
|
||||
}
|
||||
62
app/Providers/RouteBindingServiceProvider.php
Normal file
62
app/Providers/RouteBindingServiceProvider.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Data\Contact;
|
||||
use App\Data\ContactImport;
|
||||
use App\Data\Intent\Contact\SearchContactIntentByUuid;
|
||||
use App\Data\Intent\ProcessImport\SearchImportContactsIntent;
|
||||
use App\Services\Query\ImportContactsStateQuery;
|
||||
use App\Services\Query\SearchContactQuery;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class RouteBindingServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Route::bind('contact', function (string $value): Contact {
|
||||
if (! Uuid::isValid($value)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$searchIntent = new SearchContactIntentByUuid(Uuid::fromString($value));
|
||||
$contact = app(SearchContactQuery::class)->executeOne($searchIntent);
|
||||
|
||||
if ($contact === null) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return $contact;
|
||||
});
|
||||
|
||||
Route::bind('contactImport', function (string $value): ContactImport {
|
||||
if (! Uuid::isValid($value)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$searchIntent = new SearchImportContactsIntent(Uuid::fromString($value));
|
||||
$contactImport = app(ImportContactsStateQuery::class)->executeOne($searchIntent);
|
||||
|
||||
if ($contactImport === null) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return $contactImport;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user