forked from nabeelio/phpvms
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into removeLaravelHtmlFromFrontend
- Loading branch information
Showing
61 changed files
with
905 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Console\Cron; | ||
|
||
use App\Contracts\CronCommand; | ||
use Illuminate\Support\Facades\Artisan; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class ActivityLogClean extends CronCommand | ||
{ | ||
protected $signature = 'cron:activitylog-clean'; | ||
protected $description = 'Clean up old activity logs'; | ||
|
||
public function handle(): void | ||
{ | ||
$this->callEvent(); | ||
} | ||
|
||
public function callEvent(): void | ||
{ | ||
Artisan::call('activitylog:clean --force'); | ||
|
||
$output = trim(Artisan::output()); | ||
if (!empty($output)) { | ||
Log::info($output); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/Database/migrations/2024_01_20_183702_create_activity_log_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class() extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->string('log_name')->nullable(); | ||
$table->text('description'); | ||
$table->nullableUuidMorphs('subject', 'subject'); | ||
$table->nullableMorphs('causer', 'causer'); | ||
$table->json('properties')->nullable(); | ||
$table->timestamps(); | ||
$table->index('log_name'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name')); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
app/Database/migrations/2024_01_20_183703_add_event_column_to_activity_log_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class() extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) { | ||
$table->string('event')->nullable()->after('subject_type'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) { | ||
$table->dropColumn('event'); | ||
}); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
app/Database/migrations/2024_01_20_183704_add_batch_uuid_column_to_activity_log_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class() extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) { | ||
$table->uuid('batch_uuid')->nullable()->after('properties'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) { | ||
$table->dropColumn('batch_uuid'); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Contracts\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\View\View; | ||
use Spatie\Activitylog\Models\Activity; | ||
|
||
class ActivityController extends Controller | ||
{ | ||
public function index(Request $request): View | ||
{ | ||
$activities = Activity::with('causer')->orderBy('created_at', 'desc')->paginate(); | ||
|
||
return view('admin.activities.index', [ | ||
'activities' => $activities, | ||
]); | ||
} | ||
|
||
public function show(Request $request, int $id): RedirectResponse|View | ||
{ | ||
$activity = Activity::with('causer', 'subject')->find($id); | ||
|
||
if (!$activity) { | ||
flash()->error('Activity not found'); | ||
return redirect()->route('admin.activities.index'); | ||
} | ||
|
||
return view('admin.activities.show', [ | ||
'activity' => $activity, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class EnableActivityLogging | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next | ||
*/ | ||
public function handle(Request $request, Closure $next): Response | ||
{ | ||
activity()->enableLogging(); | ||
return $next($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.