add basic logging

This commit is contained in:
TimmensOne 2023-04-04 15:52:47 +02:00
parent a9bb17d7bc
commit faee0574ae
6 changed files with 34 additions and 3 deletions

View File

@ -7,6 +7,7 @@
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Gate;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Log;
class DeviceController extends Controller
{
@ -39,6 +40,8 @@ public function store(Request $request)
Device::create($formFields);
Log::info('Device saved successfully');
return redirect('/devices');
}
@ -63,6 +66,8 @@ public function update(Device $device, Request $request)
$device->update($formFields);
Log::info('Device updated successfully');
return back();
}
@ -70,6 +75,7 @@ public function destroy(Device $device): RedirectResponse
{
$this->authorize('admin-only');
$device->delete();
Log::info('Device deleted successfully');
return redirect('devices');
}

View File

@ -5,6 +5,7 @@
use App\Models\Device;
use Illuminate\Http\Request;
use App\Models\LocationTransaction;
use Illuminate\Support\Facades\Log;
class LocationTransactionController extends Controller
{
@ -23,6 +24,8 @@ public function store(Device $device, Request $request)
$formFields['device_id'] = $device->device_id;
LocationTransaction::create($formFields);
Log::info('Location saved successfully');
return redirect('/');
}
@ -42,6 +45,8 @@ public function update(LocationTransaction $location, Request $request)
$location->update($formFields);
Log::info('Location updated successfully');
return redirect('/');
}
@ -49,6 +54,9 @@ public function destroy(LocationTransaction $location)
{
$this->authorize('admin-only');
$location->delete();
Log::info('Location deleted successfully');
return back();
}
}

View File

@ -5,6 +5,7 @@
use App\Models\Device;
use App\Models\OwnerTransaction;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class OwnerTransactionController extends Controller
{
@ -23,6 +24,8 @@ public function store(Device $device, Request $request)
$formFields['device_id'] = $device->device_id;
OwnerTransaction::create($formFields);
Log::info('Owner saved successfully');
return redirect('/');
}
@ -42,6 +45,8 @@ public function update(OwnerTransaction $owner, Request $request)
$owner->update($formFields);
Log::info('Owner updated successfully');
return redirect('/');
}
@ -49,6 +54,9 @@ public function destroy(OwnerTransaction $owner)
{
$this->authorize('admin-only');
$owner->delete();
Log::info('Owner deleted successfully');
return back();
}
}

View File

@ -3,8 +3,8 @@
namespace App\Http\Controllers;
use App\Models\Device;
use App\Models\PurchasingInformation;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class PurchasingInformationController extends Controller
{
@ -27,6 +27,8 @@ public function update(Device $device, Request $request)
$device->purchasing->update($formFields);
Log::info('Purchasing Information updated successfully');
return redirect('/');
}
}

View File

@ -3,8 +3,9 @@
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Validation\Rule;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Log;
class UserController extends Controller
{
@ -29,6 +30,8 @@ public function store(Request $request)
$user = User::create($formFields);
auth()->login($user);
Log::info('User successfully created');
return redirect('/home');
}
@ -47,6 +50,8 @@ public function authenticate(Request $request)
if (auth()->attempt($formFields)) {
$request->session()->regenerate();
Log::info('User authenticated successfully');
return redirect('/home');
}
}
@ -58,6 +63,8 @@ public function logout(Request $request)
$request->session()->invalidate();
$request->session()->regenerateToken();
Log::info('User successfully logged out');
return redirect('/home');
}
}

File diff suppressed because one or more lines are too long