Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
discoverlance-com committed Feb 21, 2023
1 parent b9aa4c5 commit f865c37
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ To delete a hint:
- Click on the hint icon on the topbar.
- Click on **Delete Hint**.

### Store and Seed database with page hints

As a convienient helper, you can run the command `php artisan filament-page-hints:seeder` and it will load all your current page hints into a seeder class, `database\seeder\PageHintSeeder`.

> NOTE: If you have quotes, like single quote in your hint from the database, you might have to fix this more manually with escape (/). I was not able to find a way to fix that so for now as even `addslashes` was adding double // instead of one /, so ensure that after you generate your seeder class, you check the `$allPageHints` array (json) to make sure there are no issues with quotes.
### Adding permissions to hint operations

Because there's not a global method for assigning permissions in filament admin panel as you might be using `filament-shield` or a different package to handle your user permissions, for now, this is a suggestive approach to handling this:
Expand Down
8 changes: 4 additions & 4 deletions src/Commands/FilamentPageHintsSeederCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FilamentPageHintsSeederCommand extends Command

public function handle(): int
{
$path = database_path('seeders/PageHintsSeeder.php');
$path = database_path('seeders/PageHintSeeder.php');

if (! $this->option('force') && $this->checkForCollision(paths: [$path])) {
return static::INVALID;
Expand All @@ -43,16 +43,16 @@ public function handle(): int
});

$this->copyStubToApp(
stub: 'PageHintsSeeder',
stub: 'PageHintSeeder',
targetPath: $path,
replacements: [
'AllPageHints' => $allPageHints->all(),
]
);

$this->info('<fg=green;options=bold>PageHintsSeeder</> generated successfully.');
$this->info('<fg=green;options=bold>PageHintSeeder</> generated successfully.');
$this->line('Now you can use it in your deploy script. i.e:');
$this->line('<bg=bright-green;options=bold> php artisan db:seed --class=PageHintsSeeder </>');
$this->line('<bg=bright-green;options=bold> php artisan db:seed --class=PageHintSeeder </>');

return Command::SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion stubs/PageHintsSeeder.stub → stubs/PageHintSeeder.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Discoverlance\FilamentPageHints\Models\PageHint;

class PageHintsSeeder extends Seeder
class PageHintSeeder extends Seeder
{
/**
* Run the database seeds.
Expand Down

0 comments on commit f865c37

Please sign in to comment.