prodV1 #2

Open
RomanGolienko wants to merge 309 commits from prodV1 into main
2 changed files with 17 additions and 2 deletions
Showing only changes of commit 3c37c2b903 - Show all commits

View File

@ -11,6 +11,8 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
class FacultyController extends Controller
@ -47,6 +49,10 @@ class FacultyController extends Controller
$faculty->educational_institution_id = $validated['educational_institution_id'];
$faculty->save();
Log::channel('app')
->info('CREATE факультет {faculty} - user {user}',
['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $validated]);
return redirect()->route('faculties.index');
}
@ -64,19 +70,28 @@ class FacultyController extends Controller
public function update(UpdateFacultyRequest $request, Faculty $faculty): RedirectResponse
{
$validated = $request->validated();
$oldData = $faculty->toArray();
$faculty->name = $validated['name'];
$faculty->description = $validated['description'];
$faculty->position = $validated['position'];
$faculty->slug = $validated['slug'];
$faculty->educational_institution_id = $validated['educational_institution_id'];
$faculty->save();
Log::channel('app')
->info('UPDATE факультет {faculty} - user {user}',
['user' => Auth::user()->name, 'faculty' => $faculty->name, 'oldData' => $oldData, 'newData' => $validated]);
$faculty->save();
return redirect()->route('faculties.index');
}
public function destroy(Faculty $faculty): RedirectResponse
{
Log::channel('app')
->info('DELETE факультет {faculty} - user {user}',
['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $faculty->toArray()]);
if ($faculty->departments()->exists()) {
return back();
}

View File

@ -18,7 +18,7 @@ class StoreFacultyRequest extends FormRequest
'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:faculties,name',
'description' => 'nullable|string',
'slug' => 'nullable|string|max:255',
'slug' => 'nullable|string|max:255|unique:faculties,slug',
'educational_institution_id' => 'required|int|numeric|max:1000'
];
}