diff --git a/app/Http/Controllers/Admin/GroupsController.php b/app/Http/Controllers/Admin/GroupsController.php index e3c17ae..b690ba3 100644 --- a/app/Http/Controllers/Admin/GroupsController.php +++ b/app/Http/Controllers/Admin/GroupsController.php @@ -4,13 +4,17 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\Group_user; +use App\Models\Group_works; use App\Models\User; +use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Validator; class GroupsController extends Controller { + public $limit = 15; + // индексная страница public function index() { $groups = Group_user::query()->active()->paginate(15); @@ -18,10 +22,26 @@ class GroupsController extends Controller } // форма добавления группы - public function add() { - $editor = Auth::user()->id; - $users = User::query()->get(); - return view('admin.groups.add', compact('editor', 'users')); + public function add(Request $request) { + /*$editor = Auth::user()->id; + $users = User::query()->active()->Offset(0)->limit($this->limit)->get(); + return view('admin.groups.add', compact('editor', 'users'));*/ + $hide = false; + $total = User::query()->active()->count(); + $amt = ceil($total / $this->limit); + if ($this->limit >= $total) $hide = true; + if ($request->ajax()) { + $page = intval($request->page); + $page = (empty($page)) ? 1 : $page; + $start = ($page != 1) ? $page * $this->limit - $this->limit : 0; + $users = User::query()->active()->Offset($start)->limit($this->limit)->get(); + return view('admin.groups.ajax_add', compact('users', 'amt')); + + } else { + $editor = Auth::user()->id; + $users = User::query()->active()->Offset(0)->limit($this->limit)->get(); + return view('admin.groups.add', compact('editor', 'users', 'amt', 'hide')); + } } // форма сохранения добавленной группы @@ -38,7 +58,13 @@ class GroupsController extends Controller return redirect()->route('admin.add-group') ->withErrors($validator); } else { - Group_user::create($request->all()); + $id_group = Group_user::create($request->all())->id; + foreach ($request->usergroup as $user) { + $people = new Group_works(); + $people->group_user_id = $id_group; + $people->user_id = $user; + $people->save(); + } return redirect()->route('admin.groups') ->with('success', 'Данные были успешно сохранены'); } @@ -47,14 +73,28 @@ class GroupsController extends Controller // форма редактирования группы public function edit(Group_user $group, Request $request) { - $editor = Auth::user()->id; - $users = User::query()->get(); - return view('admin.groups.edit', compact('editor', 'group', 'users')); + //https://snipp.ru/php/loading-scrolling + $hide = false; + $total = User::query()->active()->count(); + $amt = ceil($total / $this->limit); + if ($this->limit >= $total) $hide = true; + + if ($request->ajax()) { + $page = intval($request->page); + $page = (empty($page)) ? 1 : $page; + $start = ($page != 1) ? $page * $this->limit - $this->limit : 0; + $users = User::query()->active()->Offset($start)->limit($this->limit)->get(); + return view('admin.groups.ajax', compact('users', 'group', 'amt')); + + } else { + $editor = Auth::user()->id; + $users = User::query()->active()->Offset(0)->limit($this->limit)->get(); + return view('admin.groups.edit', compact('editor', 'group', 'users', 'amt', 'hide')); + } } // форма сохранения редактированной группы public function update(Group_user $group, Request $request) { - $params = $request->all(); unset($params['usergroup']); $rules = [ diff --git a/app/Http/Controllers/Admin/InfoBloksController.php b/app/Http/Controllers/Admin/InfoBloksController.php new file mode 100644 index 0000000..93e5c8e --- /dev/null +++ b/app/Http/Controllers/Admin/InfoBloksController.php @@ -0,0 +1,90 @@ +active()->orderByDesc('sort')->orderBy('name')->paginate(15); + return view('admin.infobloks.index', compact('infobloks')); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + return view('admin.infobloks.add'); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + infobloks::create($request->all()); + return redirect()->route('admin.infobloks.index'); + } + + /** + * Display the specified resource. + * + * @param \App\Models\infobloks $infobloks + * @return \Illuminate\Http\Response + */ + public function show(infobloks $infobloks) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Models\infobloks $infoblok + * @return \Illuminate\Http\Response + */ + public function edit(infobloks $infoblok) + { + return view('admin.infobloks.edit', compact('infoblok')); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\infobloks $infobloks + * @return \Illuminate\Http\Response + */ + public function update(Request $request, infobloks $infoblok) + { + $infoblok->update($request->all()); + return redirect()->route('admin.infobloks.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Models\infobloks $infobloks + * @return \Illuminate\Http\Response + */ + public function destroy(infobloks $infoblok) + { + $infoblok->update(['is_remove' => 1]); + return redirect()->route('admin.infobloks.index'); + } +} diff --git a/app/Http/Controllers/Admin/WorkersController.php b/app/Http/Controllers/Admin/WorkersController.php index afd74b1..9c287d7 100644 --- a/app/Http/Controllers/Admin/WorkersController.php +++ b/app/Http/Controllers/Admin/WorkersController.php @@ -34,8 +34,4 @@ class WorkersController extends Controller return; } - // кабинет - справочник - блоки информации для резюме работника - public function infobloks() { - return; - } } diff --git a/app/Models/infobloks.php b/app/Models/infobloks.php index 9a67a5d..fd768aa 100644 --- a/app/Models/infobloks.php +++ b/app/Models/infobloks.php @@ -8,4 +8,14 @@ use Illuminate\Database\Eloquent\Model; class infobloks extends Model { use HasFactory; + + protected $fillable = [ + 'name', + 'is_remove', + 'sort', + ]; + + public function ScopeActive($query) { + return $query->where('is_remove', '=', '0'); + } } diff --git a/database/migrations/2023_09_08_092903_alter_infobloks_table.php b/database/migrations/2023_09_08_092903_alter_infobloks_table.php new file mode 100644 index 0000000..39d41fb --- /dev/null +++ b/database/migrations/2023_09_08_092903_alter_infobloks_table.php @@ -0,0 +1,32 @@ +integer('sort')->default(100); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('infobloks', function (Blueprint $table) { + $table->dropColumn('sort'); + }); + } +}; diff --git a/resources/views/admin/editor/index.blade.php b/resources/views/admin/editor/index.blade.php new file mode 100644 index 0000000..0e7a002 --- /dev/null +++ b/resources/views/admin/editor/index.blade.php @@ -0,0 +1,149 @@ +@extends('layout.admin', ['title' => 'Админка - Редактор сайта']) + +@section('content') + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
НазваниеСсылка
+
+ +
+

Шапка-футер сайта

+

+ Редактор шапки и подвала сайта +

+
+
+
+ Ссылка +
+
+ +
+

Реклама

+

+ Рекламные объявления сайта +

+
+
+
+ Ссылка +
+
+ +
+

SEO-сайта

+

+ Расширенные возможности seo для отдельных страниц сайта +

+
+
+
+ Ссылка +
+
+ +
+

Редактор страниц

+

+ Создание и изменение страниц с произвольным содержанием +

+
+
+
+ Ссылка +
+
+ +
+

Должности на главной

+

+ Вывод некоторых актуальных должностей на главной странице +

+
+
+
+ Ссылка +
+
+ +
+

Работодатели на главной

+

+ Вывод некоторых актуальных работодателей на главной странице +

+
+
+
+ Ссылка +
+
+
+@endsection diff --git a/resources/views/admin/groups/add.blade.php b/resources/views/admin/groups/add.blade.php index 5ec26f5..33020b8 100644 --- a/resources/views/admin/groups/add.blade.php +++ b/resources/views/admin/groups/add.blade.php @@ -1,5 +1,9 @@ @extends('layout.admin', ['title' => 'Админка - Добавление новой группы']) +@section('script') + @include('admin.groups.script') +@endsection + @section('content')

Добавление новой группы diff --git a/resources/views/admin/groups/ajax.blade.php b/resources/views/admin/groups/ajax.blade.php new file mode 100644 index 0000000..f75df9c --- /dev/null +++ b/resources/views/admin/groups/ajax.blade.php @@ -0,0 +1,14 @@ +@foreach($users as $user) + + + {{$user->id}} + + + {{$user->name}} + + + ingroup->contains('id', $group->id)) {?>checked/> + + +@endforeach + diff --git a/resources/views/admin/groups/ajax_add.blade.php b/resources/views/admin/groups/ajax_add.blade.php new file mode 100644 index 0000000..557e9d5 --- /dev/null +++ b/resources/views/admin/groups/ajax_add.blade.php @@ -0,0 +1,14 @@ +@foreach($users as $user) + + + {{$user->id}} + + + {{$user->name}} + + + + + +@endforeach + diff --git a/resources/views/admin/groups/edit.blade.php b/resources/views/admin/groups/edit.blade.php index e3e1324..f5a5fa8 100644 --- a/resources/views/admin/groups/edit.blade.php +++ b/resources/views/admin/groups/edit.blade.php @@ -1,5 +1,9 @@ @extends('layout.admin', ['title' => 'Админка - Редактирование группы']) +@section('script') + @include('admin.groups.script') +@endsection + @section('content')

Редактирование группы diff --git a/resources/views/admin/groups/form.blade.php b/resources/views/admin/groups/form.blade.php index fbcb6ea..427bab0 100644 --- a/resources/views/admin/groups/form.blade.php +++ b/resources/views/admin/groups/form.blade.php @@ -24,7 +24,8 @@ - +
+
Добавленные в группу - + @foreach($users as $user) - + @@ -44,14 +45,21 @@ {{$user->name}} @endforeach
{{$user->id}} - ingroup->contains('id', $group->id)) {?>checked/> -
ingroup->id);?>
+ ingroup->contains('id', $group->id)) {?>checked @endisset/>
- - + + @if (!$hide) +
+
+ + Погрузить пользователей + +
+
+ @endif diff --git a/resources/views/admin/groups/script.blade.php b/resources/views/admin/groups/script.blade.php new file mode 100644 index 0000000..7175e8c --- /dev/null +++ b/resources/views/admin/groups/script.blade.php @@ -0,0 +1,43 @@ + diff --git a/resources/views/admin/index.blade.php b/resources/views/admin/index.blade.php index 7776643..9a1dbcb 100644 --- a/resources/views/admin/index.blade.php +++ b/resources/views/admin/index.blade.php @@ -268,7 +268,7 @@
-

Документы-Дипломы

+

Документы-Дипломы

Справочник документы-дипломы (все блоки-документы необходимые соискателю)

diff --git a/resources/views/admin/infobloks/add.blade.php b/resources/views/admin/infobloks/add.blade.php new file mode 100644 index 0000000..41bf4d7 --- /dev/null +++ b/resources/views/admin/infobloks/add.blade.php @@ -0,0 +1,11 @@ +@extends('layout.admin', ['title' => 'Админка - Добавление документа-диплома']) + +@section('content') +

+ Добавление документа-диплома +

+
+ @csrf + @include('admin.infobloks.form') +
+@endsection diff --git a/resources/views/admin/infobloks/edit.blade.php b/resources/views/admin/infobloks/edit.blade.php new file mode 100644 index 0000000..199b542 --- /dev/null +++ b/resources/views/admin/infobloks/edit.blade.php @@ -0,0 +1,15 @@ +@extends('layout.admin', ['title' => 'Админка - Редактирование документа-диплома']) + +@section('content') +

+ Редактирование документа-диплома +

+
+ @csrf + @isset($infoblok) + @method('PUT') + @endisset + + @include('admin.infobloks.form') +
+@endsection diff --git a/resources/views/admin/infobloks/form.blade.php b/resources/views/admin/infobloks/form.blade.php new file mode 100644 index 0000000..6322468 --- /dev/null +++ b/resources/views/admin/infobloks/form.blade.php @@ -0,0 +1,22 @@ +
+
+ +
+
+ +
+
+
diff --git a/resources/views/admin/infobloks/index.blade.php b/resources/views/admin/infobloks/index.blade.php new file mode 100644 index 0000000..759a79c --- /dev/null +++ b/resources/views/admin/infobloks/index.blade.php @@ -0,0 +1,84 @@ +@extends('layout.admin', ['title' => 'Админка - Справочник Дипломы-Документы']) + +@section('script') +@endsection + +@section('search') + +@endsection + +@section('content') +
+
+ Создать стандарт документа

+ + + + + + + + + + + + @foreach($infobloks as $blok) + + + + + + + + @endforeach + +
Название документаСортировкаДата созданияИзменить
+ {{$blok->id}} + + {{$blok->name}} + + {{$blok->sort}} + + {{$blok->created_at }} + +
+ Изменить | + @csrf + @method('DELETE') + +
+
+
+ +
+ appends($_GET)->links('admin.pagginate'); ?> +
+
+@endsection diff --git a/resources/views/admin/job_titles/index.blade.php b/resources/views/admin/job_titles/index.blade.php index 03feb45..bd9fc88 100644 --- a/resources/views/admin/job_titles/index.blade.php +++ b/resources/views/admin/job_titles/index.blade.php @@ -44,6 +44,7 @@ № Родитель Должность + Сортировка Дата создания Изменить @@ -64,6 +65,9 @@ {{$job->name}} + + {{$job->sort}} + {{ $job->created_at }} diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php index 0ee4813..40d0f23 100644 --- a/resources/views/layout/admin.blade.php +++ b/resources/views/layout/admin.blade.php @@ -308,7 +308,7 @@ Категории
  • - Блоки-Дипломы + Блоки-Дипломы
  • @@ -701,7 +701,7 @@ Категории
  • - Блоки-Дипломы + Блоки-Дипломы
  • diff --git a/routes/web.php b/routes/web.php index 92d0a5d..fc2316c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,6 +3,7 @@ use App\Http\Controllers\Admin\AdminController; use App\Http\Controllers\Admin\CategoryController; use App\Http\Controllers\Admin\EmployersController; +use App\Http\Controllers\Admin\InfoBloksController; use App\Http\Controllers\Admin\JobTitlesController; use App\Http\Controllers\Admin\UsersController; use App\Http\Controllers\Admin\WorkersController; @@ -164,7 +165,9 @@ Route::group([ Route::get('group-admin', [AdminController::class, 'index'])->name('group-admin'); /////редактор////// кабинет - редактор сайта//////////////////////// - Route::get('editor-site', [CompanyController::class, 'editor'])->name('editor-site'); + Route::get('editor-site', function() { + return view('admin.editor.index'); + })->name('editor-site'); // кабинет - редактор шапки-футера сайта Route::get('edit-blocks', [CompanyController::class, 'editblocks'])->name('edit-blocks'); @@ -200,7 +203,11 @@ Route::group([ Route::get('static-ads', [EmployersController::class, 'static_ads'])->name('static-ads'); // кабинет - справочник - блоки информации (дипломы и документы) для резюме работника - Route::get('infobloks', [WorkersController::class, 'infobloks'])->name('infobloks'); + /* + * CRUD-операции над справочником дипломы и документы + */ + //Route::get('infobloks', [WorkersController::class, 'infobloks'])->name('infobloks'); + Route::resource('infobloks', InfoBloksController::class, ['except' => ['show']]); // кабинет - роли пользователя Route::get('roles', [UsersController::class, 'roles'])->name('roles');