Skip to content

Commit

Permalink
activity configurations updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Raza9798 committed Jun 17, 2024
1 parent 7b5fbe8 commit b3e18df
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
34 changes: 30 additions & 4 deletions src/Controller/ActivityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,52 @@
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Intelrx\Rapidkit\assets\Banner;

class ActivityController extends Controller
{
public function setup(){
File::makeDirectory(app_path('Traits'));
$stubPath = dirname(__DIR__, 2) . '/src/stubs/config/HasActivityLog.stub';
$this->createTraitsDirectory();
$this->createActivityLogTrait();
$this->publishActivityLogAssets();
$this->runActivityLoggerMigrations();

}

protected function createTraitsDirectory(){
$dir = app_path('Traits');
if (!File::exists($dir)) {
File::makeDirectory($dir);
}
else{
(new Banner())->warn('Traits directory already exists');
}
}

protected function createActivityLogTrait(){
$stubPath = dirname(__DIR__, 2) . '/src/stubs/traits/HasActivityLog.stub';
$traitPath = app_path('Traits/HasActivityLog.php');
$stubContent = File::get($stubPath);
if (!File::exists($traitPath)) {
File::put($traitPath, $stubContent);
}

else{
(new Banner())->warn('HasActivityLog trait already exists');
}
}

protected function publishActivityLogAssets(){
Artisan::call('vendor:publish', [
'--provider' => 'Spatie\Activitylog\ActivitylogServiceProvider',
'--tag' => 'activitylog-migrations'
]);
Artisan::call('migrate');
Artisan::call("vendor:publish", [
"--provider" => "Spatie\Activitylog\ActivitylogServiceProvider",
"--tag" => "activitylog-config"
]);
}

protected function runActivityLoggerMigrations(){
Artisan::call('migrate');
}
}
2 changes: 1 addition & 1 deletion src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class Config
{
const VERSION = '1.8.1';
const VERSION = '1.8.2';
}

0 comments on commit b3e18df

Please sign in to comment.