git add .

git commit "feat: implement activity logging for tours and flights"
This commit is contained in:
2026-08-19 14:59:26 +03:30
parent 7cf68cc02f
commit 4d8839e802
9 changed files with 326 additions and 3 deletions
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\ActivityLog;
use Illuminate\Http\Request;
class ActivityLogController extends Controller
{
//
public function index()
{
$logs=ActivityLog::with('admin')
->latest()
->paginate(4);
return view('admin.activityLog.index',compact('logs'));
}
}
@@ -20,8 +20,16 @@ class DashboardController extends Controller
$flightsCount = Flight::count();
$tourViews= Tour::query()
->selectRaw('DATE(create_at) as date,SUM(views) as total')
->where('created_at','>=',now()->subDays(9))
->qroupBy('date')
->orderBy('date')
->get();
return view('admin.dashboard',compact('adminsCount',
'usersCount','toursCount','flightsCount'
'usersCount','toursCount','flightsCount','tourViews'
));
}
}
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\FlightStoreRequest;
use App\Models\ActivityLog;
use App\Models\Flight;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@@ -48,8 +49,15 @@ class FlightController extends Controller
$data['created_by'] = auth('admin')->id();
Flight::create($data);
$flight = Flight::create($data);
ActivityLog::create([
'admin_id' => auth('admin')->id(),
'action' => 'create',
'model' => 'Flight',
'model_id' => $flight->id,
'description' => 'ثبت پرواز جدید',
]);
DB::commit();
@@ -107,6 +115,13 @@ class FlightController extends Controller
$flight->update($data);
ActivityLog::create([
'admin_id' => auth('admin')->id(),
'action' => 'update',
'model' => 'Flight',
'model_id' => $flight->id,
'description' => 'ویرایش اطلاعات پرواز',
]);
DB::commit();
@@ -136,6 +151,13 @@ class FlightController extends Controller
}
ActivityLog::create([
'admin_id' => auth('admin')->id(),
'action' => 'delete',
'model' => 'Flight',
'model_id' => $flight->id,
'description' => 'حذف پرواز',
]);
$flight->delete();
+26 -1
View File
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\TourStoreRequest;
use App\Models\ActivityLog;
use App\Models\Tour;
use App\Models\TravelType;
use Illuminate\Http\Request;
@@ -50,7 +51,15 @@ class TourController extends Controller
$data['created_by'] = auth('admin')->id();
Tour::create($data);
$tour = Tour::create($data);
ActivityLog::create([
'admin_id' => auth('admin')->id(),
'action' => 'create',
'model' => 'Tour',
'model_id' => $tour->id,
'description' => 'ثبت تور جدید',
]);
DB::commit();
@@ -109,6 +118,14 @@ class TourController extends Controller
$tour->update($data);
ActivityLog::create([
'admin_id' => auth('admin')->id(),
'action' => 'create',
'model' => 'Tour',
'model_id' => $tour->id,
'description' => 'ویرایش تور',
]);
DB::commit();
@@ -138,6 +155,14 @@ class TourController extends Controller
}
ActivityLog::create([
'admin_id' => auth('admin')->id(),
'action' => 'create',
'model' => 'Tour',
'model_id' => $tour->id,
'description' => 'حذف تور',
]);
$tour->delete();