Skip to content

Commit

Permalink
feat: add activity-log installation
Browse files Browse the repository at this point in the history
  • Loading branch information
emilhorlyck committed Oct 17, 2023
1 parent 2feac46 commit 07fc24f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/Commands/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class InitCommand extends Command

public function handle(): int
{
// - [x] Readme
// - [x] Install blueprint
// - [ ] Setup backup
// - [x] API Documentation
// - [x] Generate ERD
// - [x] Readme
// - [ ] Activity log for models
// - [ ] Conventional commit script
// - [ ] Release script
Expand All @@ -40,6 +40,7 @@ public function handle(): int
// 'backup' => 'Setup backup',
'api-docs' => 'API Documentation',
'erd' => 'Generate ERD',
'activity-log' => 'Activity log for models',
// 'conventional-commits' => 'Conventional commit script',
// 'release' => 'Release script',
// 'pre-push' => 'Pre push git hook for pest',
Expand Down Expand Up @@ -272,6 +273,32 @@ public function handle(): int
]);
}

// Activity log for models
if($chosenSteps->contains('activity-log')) {
$this->info('Installing activity log...');
exec('composer require spatie/laravel-activitylog');
info('activity log installed successfully.');
exec('php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"');
exec('php artisan migrate');
info('activity log migrations migrated successfully.');

$this->addTooReadme([
'### [laravel-activitylog](https://spatie.be/docs/laravel-activitylog/v4/basic-usage/logging-activity)',
'#### Usage',
'',
'Log an activity',
'\`\`\`php',
'activity()->log(\'Look, I logged something\');',
'\`\`\`',

'The package can automatically log events such as when a model is created, updated and deleted.',
'To make this work all you need to do is let your model use the Spatie\Activitylog\Traits\LogsActivity-trait.',
'',
'[Logging model events](https://spatie.be/docs/laravel-activitylog/v4/advanced-usage/logging-model-events)',
'',
]);
}

// Conventional commit script

// Release script
Expand Down

0 comments on commit 07fc24f

Please sign in to comment.