fix : complete Activity log in admin side
This commit is contained in:
@@ -169,7 +169,7 @@ class FlightController extends Controller
|
||||
$fileId = $uploadedFile->id;
|
||||
}
|
||||
|
||||
Flight::create([
|
||||
$flight = Flight::create([
|
||||
'title' => $request->input('title'),
|
||||
'file_id' => $fileId,
|
||||
'airline_id' => $request->input('airline_id'),
|
||||
@@ -183,8 +183,12 @@ class FlightController extends Controller
|
||||
'views' => 0,
|
||||
'description' => $request->input('description'),
|
||||
'status' => $request->input('status'),
|
||||
'created_by' => auth('admin')->id(),
|
||||
'updated_by' => auth('admin')->id(),
|
||||
]);
|
||||
|
||||
logActivity('flights', $flight->id, 'created');
|
||||
|
||||
DB::commit();
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
@@ -227,6 +231,12 @@ class FlightController extends Controller
|
||||
|
||||
public function update(Request $request, Flight $flight)
|
||||
{
|
||||
$before = $flight->only([
|
||||
'title', 'airline_id', 'flight_type', 'departure_time',
|
||||
'departure_airport_id', 'arrival_airport_id', 'price',
|
||||
'summary', 'capacity', 'description', 'status',
|
||||
]);
|
||||
|
||||
$request->validate([
|
||||
'title' => [
|
||||
'required',
|
||||
@@ -327,6 +337,12 @@ class FlightController extends Controller
|
||||
'capacity' => $request->input('capacity'),
|
||||
'description' => $request->input('description'),
|
||||
'status' => $request->input('status'),
|
||||
'updated_by' => auth('admin')->id(),
|
||||
]);
|
||||
|
||||
logActivity('flights', $flight->id, 'updated', [
|
||||
'before' => $before,
|
||||
'after' => $flight->only(array_keys($before)),
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
@@ -357,6 +373,7 @@ class FlightController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
logActivity('flights', $flight->id, 'deleted');
|
||||
$flight->delete();
|
||||
|
||||
return redirect()->route('admin.flights.index')->withErrors([
|
||||
|
||||
Reference in New Issue
Block a user