-
Notifications
You must be signed in to change notification settings - Fork 139
Fix issue#1767 #1794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix issue#1767 #1794
Changes from all commits
dbdeeaa
91ea2d2
e1d0629
0d1def1
fac7db1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| /** | ||
| * Run the migrations. | ||
| */ | ||
| public function up(): void | ||
| { | ||
| Schema::table('users', function (Blueprint $table) { | ||
| $table->renameColumn('is_admin', 'admin'); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rnik82 а для чего переименовывать поле?) Оно ведь булево - верно названо? |
||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Reverse the migrations. | ||
| */ | ||
| public function down(): void | ||
| { | ||
| Schema::table('users', function (Blueprint $table) { | ||
| $table->renameColumn('admin', 'is_admin'); | ||
| }); | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ public function run(): void | |
| 'name' => 'Admin', | ||
| 'email' => '[email protected]', | ||
| 'password' => bcrypt('password'), | ||
| 'is_admin' => true, | ||
| 'admin' => true, | ||
| ]); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| @extends('layouts.app') | ||
|
|
||
| @section('title', __('admin.users.edit_user', ['name' => $user->name])) | ||
|
|
||
| @section('content') | ||
| <div class="container"> | ||
| <div class="row"> | ||
| <div class="col-md-3"> | ||
| {{-- Админское меню --}} | ||
| <div class="list-group"> | ||
| <a href="{{ route('admin.users.index') }}" | ||
| class="list-group-item list-group-item-action {{ request()->routeIs('admin.users.*') ? 'active' : '' }}"> | ||
| {{ __('admin.users.title') }} | ||
| </a> | ||
| <a href="{{ route('admin.comments.index') }}" | ||
| class="list-group-item list-group-item-action {{ request()->routeIs('admin.comments.*') ? 'active' : '' }}"> | ||
| {{ __('admin.comments.title') }} | ||
| </a> | ||
| <a href="{{ route('admin.solutions.index') }}" | ||
| class="list-group-item list-group-item-action {{ request()->routeIs('admin.solutions.*') ? 'active' : '' }}"> | ||
| {{ __('admin.solutions.title') }} | ||
| </a> | ||
| </div> | ||
| </div> | ||
| <div class="col-md-9"> | ||
| <div class="card"> | ||
| <div class="card-header"> | ||
| <h5 class="card-title mb-0"> | ||
| {{ __('admin.users.edit') }} | ||
| </h5> | ||
| </div> | ||
| <div class="card-body"> | ||
| {{ html()->modelForm($user, 'PUT', route('admin.users.update', $user))->open() }} | ||
|
|
||
| <div class="mb-3"> | ||
| {{ html()->label(__('account.name'), 'name')->class('form-label') }} | ||
| {{ html()->text('name') | ||
| ->class('form-control') | ||
| ->required() }} | ||
| </div> | ||
|
|
||
| <div class="mb-3"> | ||
| {{ html()->label(__('account.github_name'), 'github_name')->class('form-label') }} | ||
| {{ html()->text('github_name') | ||
| ->class('form-control') }} | ||
| </div> | ||
|
|
||
| <div class="mb-3"> | ||
| <div class="form-check"> | ||
| {{ html()->checkbox('admin') | ||
| ->class('form-check-input') | ||
| ->value(1) | ||
| ->checked($user->admin) }} | ||
| {{ html()->label(__('account.admin'), 'admin') | ||
| ->class('form-check-label') }} | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="d-flex gap-2"> | ||
| <button type="submit" class="btn btn-primary"> | ||
| {{ __('layout.common.save') }} | ||
| </button> | ||
| <a href="{{ route('admin.users.index') }}" class="btn btn-secondary"> | ||
| {{ __('layout.common.cancel') }} | ||
| </a> | ||
| </div> | ||
|
|
||
| {{ html()->closeModelForm() }} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| @endsection |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ class="nav-link p-2">{{ __('layout.nav.sicp_read') }}</a></li> | |
| <li class="nav-item"><a href="{{ TemplateHelper::getBookLink($currentLocale) }}" | ||
| class="nav-link link-info p-2">{{ __('layout.nav.sicp_book') }}</a></li> | ||
| @auth | ||
| @if(auth()->user()->is_admin) | ||
| @if(auth()->user()->admin) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. давай кстати тут сразу поменяем, не проверку роли, а через проверку политик ( |
||
| <li class="nav-item dropdown"> | ||
| <a class="nav-link dropdown-toggle p-2" href="#" id="adminDropdown" role="button" | ||
| data-bs-toggle="dropdown" aria-expanded="false"> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тк admin в форме - это чекбокс, то стоит его так и назвать.
плюс - валидация. https://laravel.com/docs/12.x/validation#rule-accepted