diff --git a/README.md b/README.md index e2c1035e7b..7cd1e53e66 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ cd [appName] ```bash composer install filament/filament # See note below php artisan migrate +php artisan vendor:publish --tag=filament-seeds +composer dump-autoload +php artisan db:seed --class=FilamentSeeder ``` > ToDo: Add to Packagist (for now you will need to clone and [symlink the package](https://calebporzio.com/bash-alias-composer-link-use-local-folders-as-composer-dependancies)). @@ -36,4 +39,14 @@ php artisan filament:user ## Upgrading -There are no special requirements for upgrading, other than changing `^x.xx` version in your composer.json and running `composer update` as well as `php artisan migrate`. +Changing `^x.xx` version in your composer.json. + +Run the following commands: + +```bash +composer update +php artisan migrate +php artisan vendor:publish --tag=filament-seeds --force +composer dump-autoload +php artisan db:seed --class=FilamentSeeder +``` diff --git a/database/data/permissions.php b/database/data/permissions.php new file mode 100644 index 0000000000..e8cd71ed6a --- /dev/null +++ b/database/data/permissions.php @@ -0,0 +1,39 @@ + 'view users', + 'guard_name' => 'web', + 'is_system' => 1, + ], + + [ + 'name' => 'edit users', + 'guard_name' => 'web', + 'is_system' => 1, + ], + + [ + 'name' => 'create users', + 'guard_name' => 'web', + 'is_system' => 1, + ], + + [ + 'name' => 'edit user permissions', + 'guard_name' => 'web', + 'is_system' => 1, + ], + +]; \ No newline at end of file diff --git a/database/migrations/2020_04_06_100000_add_is_system_to_permissions_table.php b/database/migrations/2020_04_06_100000_add_is_system_to_permissions_table.php new file mode 100644 index 0000000000..78a192d0ec --- /dev/null +++ b/database/migrations/2020_04_06_100000_add_is_system_to_permissions_table.php @@ -0,0 +1,43 @@ +tableName, function (Blueprint $table) { + if (!Schema::hasColumn($this->tableName, 'is_system')) { + $table->boolean('is_system')->default(0)->after('guard_name'); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table($this->tableName, function (Blueprint $table) { + if (Schema::hasColumn($this->tableName, 'avatar')) { + $table->dropColumn('is_system'); + } + }); + } +} diff --git a/database/seeds/FilamentPermissionSeeder.php b/database/seeds/FilamentPermissionSeeder.php new file mode 100644 index 0000000000..53358f5764 --- /dev/null +++ b/database/seeds/FilamentPermissionSeeder.php @@ -0,0 +1,21 @@ +call(FilamentPermissionSeeder::class); + } +} \ No newline at end of file diff --git a/src/Filament.php b/src/Filament.php index 5dd93ebb9e..af61c3b4c9 100644 --- a/src/Filament.php +++ b/src/Filament.php @@ -20,6 +20,17 @@ class Filament { return __DIR__.'/../'.ltrim($path, '/'); } + /** + * `database` path + * + * @param string $path + * @return string + */ + public function databasePath($path = '') + { + return $this->basePath('database/'.ltrim($path, '/')); + } + /** * `route` path * diff --git a/src/FilamentServiceProvider.php b/src/FilamentServiceProvider.php index 39f4428669..c5b0f7fc4c 100644 --- a/src/FilamentServiceProvider.php +++ b/src/FilamentServiceProvider.php @@ -226,6 +226,11 @@ class FilamentServiceProvider extends ServiceProvider $this->publishes([ $this->packagePath.'config/filament.php' => config_path('filament.php'), ], 'filament-config'); + + $this->publishes([ + $this->packagePath.'database/seeds/FilamentSeeder.php' => database_path('seeds/FilamentSeeder.php'), + $this->packagePath.'database/seeds/FilamentPermissionSeeder.php' => database_path('seeds/FilamentPermissionSeeder.php'), + ], 'filament-seeds'); } }