TASKS ДОПОЛНЕНИЯ 15‐19 - RadLeoOFC/laravel-admin-panel GitHub Wiki
"Is it normal that on the main page it says dashboard, but when clicking on the Admin Panel button, it redirects to main?"
-
Analyzed the navigation behavior:
- The sidebar
Admin Panelbutton redirected to/dashboard. - The header
Admin Panelbutton redirected to/main. - The
mainpage displayed the title Dashboard, which was misleading.
- The sidebar
-
Checked routes in
routes/web.php:- Ensured that the
/dashboardand/mainroutes were correctly defined. - Confirmed that the wrong title was being displayed on the
mainpage.
- Ensured that the
-
Implemented Fixes:
- Updated the title on the
mainpage to correctly display Main instead of Dashboard. - Ensured that sidebar navigation and header buttons led to the expected destinations.
- Updated the title on the
✅ The navigation logic is now consistent. The Admin Panel button in the sidebar leads to the Dashboard, while the Admin Panel button in the header leads to Main.
✅ The page titles now correctly reflect their content.
Insert Screenshot: Navigation before the fix
(Скриншот: Главная страница с неправильным заголовком)
Insert Screenshot: Navigation after the fix
(Скриншот: Исправленный заголовок и корректная навигация)
"A regular user can manually enter or edit the price field in a membership. Is this behavior correct?"
-
Added automatic price calculation in
MembershipController.php:private function calculateMembershipPrice($type, $startDate, $endDate) { $start = \Carbon\Carbon::parse($startDate); $end = \Carbon\Carbon::parse($endDate); $days = $start->diffInDays($end); if ($type === 'daily') return $days * 5; // $5 per day if ($type === 'monthly') return ceil($days / 30) * 100; // $100 per month if ($type === 'yearly') return ceil($days / 365) * 1000; // $1000 per year return 0; }
-
Modified views (
create.blade.php,edit.blade.php):- Removed the price input field for non-admin users in the create form.
-
Made the price field
readonlyfor non-admins in the edit form.
✅ Now, only admins can modify the price.
✅ The price is automatically calculated based on the membership duration.
Insert Screenshot: Before fix (user could edit price)
(Скриншот: Форма с возможностью изменения цены)
Insert Screenshot: After fix (price field removed or read-only for users)
(Скриншот: Форма после исправления)
"When a validation error occurs, the selected desk and membership type values are not retained in the form."
-
Identified the issue in
create.blade.php:<select name="desk_id" id="desk_id" class="form-select" value="{{ old('desk_id') }}"/>
- The
valueattribute inselectdoes not work as expected.
- The
-
Implemented Fix:
- Updated the
selectelements to correctly retain the previous input:
<select name="desk_id" id="desk_id" class="form-select"> @foreach($desks as $desk) <option value="{{ $desk->id }}" {{ old('desk_id') == $desk->id ? 'selected' : '' }}> {{ $desk->name }} </option> @endforeach </select>
- The same fix was applied to the
membership_typefield.
- Updated the
✅ Now, selected values remain after validation errors, preventing users from re-entering data.
Insert Screenshot: Before fix (values reset on validation error)
(Скриншот: Ошибки валидации с пустыми полями)
Insert Screenshot: After fix (values retained after validation error)
(Скриншот: Ошибки валидации, но данные сохранены)