chore: update seeders, add MockDataSeeder and AssignAllPermissions command
- DatabaseSeeder: replace old seeders with MockDataSeeder - RolesSeeder: update role definitions - Add AssignAllPermissions artisan command - Register MockDataSeeder in AppServiceProvider - Register command in ConsoleKernel
This commit is contained in:
@@ -49,8 +49,10 @@ use Carbon\Carbon;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Facades\FilamentView;
|
||||
use Filament\Tables\View\TablesRenderHook;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
use Illuminate\Support\Facades\Str;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Sleep;
|
||||
use Intervention\Image\Facades\Image;
|
||||
@@ -70,6 +72,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
self::configureFactoryResolution();
|
||||
self::setObserversByModel();
|
||||
self::setLocaleTime();
|
||||
Model::preventLazyLoading(!app()->isProduction());
|
||||
@@ -81,6 +84,21 @@ class AppServiceProvider extends ServiceProvider
|
||||
});
|
||||
}
|
||||
|
||||
private static function configureFactoryResolution(): void
|
||||
{
|
||||
Factory::guessFactoryNamesUsing(function (string $modelName) {
|
||||
$appNamespace = 'App\\';
|
||||
|
||||
if (str_starts_with($modelName, $appNamespace.'Models\\')) {
|
||||
$modelName = substr($modelName, strlen($appNamespace.'Models\\'));
|
||||
} else {
|
||||
$modelName = substr($modelName, strlen($appNamespace));
|
||||
}
|
||||
|
||||
return 'Database\\Factories\\'.$modelName.'Factory';
|
||||
});
|
||||
}
|
||||
|
||||
private static function setObserversByModel() : void {
|
||||
Page::observe(PageObserver::class);
|
||||
Post::observe(PostObserver::class);
|
||||
|
||||
Reference in New Issue
Block a user