TRF Certest first commit

This commit is contained in:
2025-02-26 08:57:46 +01:00
commit 3ce064a108
2524 changed files with 475404 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
<?php
namespace Vanguard\Providers;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\ServiceProvider;
use Vanguard\Repositories\Country\CountryRepository;
use Vanguard\Repositories\Country\EloquentCountry;
use Vanguard\Repositories\Permission\EloquentPermission;
use Vanguard\Repositories\Permission\PermissionRepository;
use Vanguard\Repositories\Role\EloquentRole;
use Vanguard\Repositories\Role\RoleRepository;
use Vanguard\Repositories\Session\DbSession;
use Vanguard\Repositories\Session\SessionRepository;
use Vanguard\Repositories\User\EloquentUser;
use Vanguard\Repositories\User\UserRepository;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Carbon::setLocale(config('app.locale'));
config(['app.name' => setting('app_name')]);
\Illuminate\Database\Schema\Builder::defaultStringLength(191);
Factory::guessFactoryNamesUsing(function (string $modelName) {
return 'Database\Factories\\'.class_basename($modelName).'Factory';
});
\Illuminate\Pagination\Paginator::useBootstrap();
}
/**
* Register any application services.
*/
public function register(): void
{
$this->app->singleton(UserRepository::class, EloquentUser::class);
$this->app->singleton(RoleRepository::class, EloquentRole::class);
$this->app->singleton(PermissionRepository::class, EloquentPermission::class);
$this->app->singleton(SessionRepository::class, DbSession::class);
$this->app->singleton(CountryRepository::class, EloquentCountry::class);
if ($this->app->environment('local')) {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
$this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
}
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
namespace Vanguard\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Vanguard\User;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
'Vanguard\Model' => 'Vanguard\Policies\ModelPolicy',
];
/**
* Register any application authentication / authorization services.
*/
public function boot(): void
{
\Blade::directive('role', function ($expression) {
return "<?php if (\\Auth::user()->hasRole({$expression})) : ?>";
});
\Blade::directive('endrole', function ($expression) {
return '<?php endif; ?>';
});
\Blade::directive('permission', function ($expression) {
return "<?php if (\\Auth::user()->hasPermission({$expression})) : ?>";
});
\Blade::directive('endpermission', function ($expression) {
return '<?php endif; ?>';
});
\Gate::define('manage-session', function (User $user, $session) {
if ($user->hasPermission('users.manage')) {
return true;
}
return (int) $user->id === (int) $session->user_id;
});
}
}
@@ -0,0 +1,34 @@
<?php
namespace Vanguard\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Broadcast::routes();
/*
* Authenticate the user's personal channel...
*/
Broadcast::channel('Vanguard.User.*', function ($user, $userId) {
return (int) $user->id === (int) $userId;
});
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}
}
+56
View File
@@ -0,0 +1,56 @@
<?php
namespace Vanguard\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Events\Verified;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Vanguard\Events\User\Banned;
use Vanguard\Events\User\LoggedIn;
use Vanguard\Listeners\Login\UpdateLastLoginTimestamp;
use Vanguard\Listeners\Registration\SendSignUpNotification;
use Vanguard\Listeners\Users\ActivateUser;
use Vanguard\Listeners\Users\InvalidateSessions;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
SendSignUpNotification::class,
],
LoggedIn::class => [
UpdateLastLoginTimestamp::class,
],
Banned::class => [
InvalidateSessions::class,
],
Verified::class => [
ActivateUser::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
//
}
/**
* Determine if events and listeners should be automatically discovered.
*/
public function shouldDiscoverEvents(): bool
{
return false;
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace Vanguard\Providers;
use Illuminate\Support\ServiceProvider;
class FortifyServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}
+114
View File
@@ -0,0 +1,114 @@
<?php
namespace Vanguard\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Route;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Vanguard\Repositories\Role\RoleRepository;
use Vanguard\Repositories\Session\SessionRepository;
use Vanguard\Repositories\User\UserRepository;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/';
/**
* This namespace is applied to the controller routes in your web routes file.
* In addition, it is set as the URL generator's root namespace.
*/
protected string $webNamespace = 'Vanguard\Http\Controllers\Web';
/**
* This namespace is applied to the controller routes in your api routes file.
*/
protected string $apiNamespace = 'Vanguard\Http\Controllers\Api';
/**
* Define your route model bindings, pattern filters, etc.
*/
public function boot(): void
{
parent::boot();
$this->bindUser();
$this->bindRole();
$this->bindSession();
}
/**
* Define the routes for the application.
*/
public function map(): void
{
if ($this->app['config']->get('auth.expose_api')) {
$this->mapApiRoutes();
}
$this->mapWebRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*/
protected function mapWebRoutes(): void
{
Route::group([
'namespace' => $this->webNamespace,
'middleware' => 'web',
], function ($router) {
require base_path('routes/web.php');
});
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*/
protected function mapApiRoutes(): void
{
Route::group([
'middleware' => 'api',
'namespace' => $this->apiNamespace,
'prefix' => 'api',
], function () {
require base_path('routes/api.php');
});
}
private function bindUser(): void
{
$this->bindUsingRepository('user', UserRepository::class);
}
private function bindRole(): void
{
$this->bindUsingRepository('role', RoleRepository::class);
}
private function bindSession(): void
{
$this->bindUsingRepository('session', SessionRepository::class);
}
private function bindUsingRepository($entity, $repository, $method = 'find'): void
{
Route::bind($entity, function ($id) use ($repository, $method) {
if ($object = app($repository)->$method($id)) {
return $object;
}
throw new NotFoundHttpException('Resource not found.');
});
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
namespace Vanguard\Providers;
use Vanguard\Plugins\VanguardServiceProvider as BaseVanguardServiceProvider;
use Vanguard\Support\Plugins\Dashboard\Widgets\BannedUsers;
use Vanguard\Support\Plugins\Dashboard\Widgets\LatestRegistrations;
use Vanguard\Support\Plugins\Dashboard\Widgets\NewUsers;
use Vanguard\Support\Plugins\Dashboard\Widgets\RegistrationHistory;
use Vanguard\Support\Plugins\Dashboard\Widgets\TotalUsers;
use Vanguard\Support\Plugins\Dashboard\Widgets\UnconfirmedUsers;
use Vanguard\Support\Plugins\Dashboard\Widgets\UserActions;
use Vanguard\UserActivity\Widgets\ActivityWidget;
class VanguardServiceProvider extends BaseVanguardServiceProvider
{
/**
* List of registered plugins.
*/
protected function plugins(): array
{
return [
\Vanguard\Support\Plugins\Dashboard\Dashboard::class,
\Vanguard\Support\Plugins\Users::class,
\Vanguard\UserActivity\UserActivity::class,
\Vanguard\Support\Plugins\RolesAndPermissions::class,
\Vanguard\Support\Plugins\Settings::class,
\Vanguard\Announcements\Announcements::class,
];
}
/**
* Dashboard widgets.
*/
protected function widgets(): array
{
return [
UserActions::class,
TotalUsers::class,
NewUsers::class,
BannedUsers::class,
UnconfirmedUsers::class,
RegistrationHistory::class,
LatestRegistrations::class,
ActivityWidget::class,
];
}
}