diff --git a/app/Http/Controllers/Admin/AdminController.php b/app/Http/Controllers/Admin/AdminController.php index 5869d34..a5d4c23 100644 --- a/app/Http/Controllers/Admin/AdminController.php +++ b/app/Http/Controllers/Admin/AdminController.php @@ -5,8 +5,10 @@ namespace App\Http\Controllers\Admin; use App\Classes\Tools; use App\Http\Controllers\Controller; use App\Http\Requests\CompanyRequest; +use App\Http\Requests\RequestPosition; use App\Models\Company; use App\Models\Employer; +use App\Models\Positions; use App\Models\User; use Carbon\Carbon; use Illuminate\Http\Request; @@ -346,5 +348,34 @@ class AdminController extends Controller return redirect()->route('admin.config'); } + public function position() { + $Positions = Positions::query()->get(); + return view('admin.positions.position', compact('Positions')); + } + + public function position_add() { + return view('admin.positions.add'); + } + + public function position_add_save(RequestPosition $request) { + $all = $request->all(); + $position = Positions::create($all); + return redirect()->route('admin.position'); + } + public function position_edit(Positions $position) { + return view('admin.positions.edit', compact('position')); + } + + public function position_update(Positions $position, RequestPosition $request) { + $all = $request->all(); + unset($all['_token']); + $status = $position->update($all); + return redirect()->route('admin.position'); + } + + public function position_delete(Positions $position) { + $position->delete(); + return redirect()->route('admin.position'); + } } diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index ddaa9e8..f5dcb49 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -16,6 +16,7 @@ use App\Models\Job_title; use App\Models\Like_vacancy; use App\Models\Like_worker; use App\Models\News; +use App\Models\Positions; use App\Models\reclame; use App\Models\User; use Illuminate\Http\Request; @@ -38,34 +39,21 @@ class MainController extends Controller ->GroupBy('categories.id') ->get(); - $flot_paluba = DB::table('ad_jobs')->selectRaw('DISTINCT(job_titles.name), job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt')-> - join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> - where('position_ship', 'Палуба'); + $Position = Positions::query()->get(); + $BigFlot = Array(); + foreach ($Position as $position) { + $BigFlot[] = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> + orderBy('job_titles.sort')-> + join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> + where('position_ship', "$position->name")-> + groupby('job_title_id','position_ship')-> + get(); + } - - $flot_paluba = $flot_paluba->groupby('job_title_id')->get(); - $flot_MO = DB::table('ad_jobs')->selectRaw('DISTINCT(job_titles.name), job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt')-> - join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> - where('position_ship', '=', 'МО'); - - $flot_MO = $flot_MO->groupby('ad_jobs.id')->get(); - - $flot_radovie = DB::table('ad_jobs')->selectRaw('DISTINCT(job_titles.name), job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt')-> - join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> - where('position_ship', '=', 'Рядовые'); - - $flot_radovie = $flot_radovie->groupby('ad_jobs.id')->get(); - - $flot_prochee = DB::table('ad_jobs')->selectRaw('DISTINCT(job_titles.name), job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt')-> - join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> - where('position_ship', '=', 'Прочее'); - $flot_prochee = $flot_prochee->groupby('ad_jobs.id')->get(); $employers = employers_main::query()->with('employer')->orderBy('id')->limit(8)->get(); $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); - return view('index', compact('news', 'categories', 'employers', 'vacancy', - 'flot_paluba', 'flot_MO', 'flot_radovie', 'flot_prochee' - )); + return view('index', compact('news', 'categories', 'employers', 'vacancy', 'BigFlot', 'Position')); } public function search_vacancies(Request $request) { @@ -137,45 +125,25 @@ class MainController extends Controller $categories = $categories->OrderByDesc('created_at')->GroupBy('categories.id')->get(); + $Position = Positions::query()->get(); - $flot_paluba = DB::table('ad_jobs')->selectRaw('DISTINCT(job_titles.name), job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt')-> - join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> - where('position_ship', 'Палуба'); - if (!empty($request->get('job'))) { - $flot_paluba = $flot_paluba->where('job_title_id', '=', $request->get('job')); - } - $flot_paluba = $flot_paluba->groupby('job_title_id')->get(); - - $flot_MO = DB::table('ad_jobs')->selectRaw('DISTINCT(job_titles.name), job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt')-> - join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> - where('position_ship', '=', 'МО'); - if (!empty($request->get('job'))) { - $flot_MO = $flot_MO->where('job_title_id', '=', $request->get('job')); - } - $flot_MO = $flot_MO->groupby('ad_jobs.id')->get(); - - $flot_radovie = DB::table('ad_jobs')->selectRaw('DISTINCT(job_titles.name), job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt')-> - join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> - where('position_ship', '=', 'Рядовые'); - if (!empty($request->get('job'))) { - $flot_radovie = $flot_radovie->where('job_title_id', '=', $request->get('job')); - } - $flot_radovie = $flot_radovie->groupby('ad_jobs.id')->get(); - - $flot_prochee = DB::table('ad_jobs')->selectRaw('DISTINCT(job_titles.name), job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt')-> - join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> - where('position_ship', '=', 'Прочее'); - if (!empty($request->get('job'))) { - $flot_prochee = $flot_prochee->where('job_title_id', '=', $request->get('job')); + $BigFlot = Array(); + foreach ($Position as $position) { + $War_flot = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> + orderBy('job_titles.sort')-> + join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> + where('position_ship', "$position->name"); + if (($request->has('job')) && ($request->get('job') > 0)) { + $War_flot = $War_flot->where('job_title_id', $request->get('job')); + } + $War_flot = $War_flot->groupby('job_title_id','position_ship')->get(); + $BigFlot[] = $War_flot; } - $flot_prochee = $flot_prochee->groupby('ad_jobs.id')->get(); - if ($request->ajax()) { - return view('ajax.new_sky', compact('categories', 'flot_paluba', 'flot_MO', 'flot_radovie', 'flot_prochee')); + return view('ajax.new_sky', compact('categories', 'BigFlot', 'Position')); } else { - return view('new_sky', compact('Job_title', 'categories', - 'flot_paluba', 'flot_MO', 'flot_radovie', 'flot_prochee')); + return view('new_sky', compact('Job_title', 'categories', 'BigFlot', 'Position')); } } @@ -416,7 +384,7 @@ class MainController extends Controller //Детальная новость public function detail_new(News $new) { - // Выборка + // Наборка $Query = News::query()->where('id', $new->id)->get(); $title = $Query[0]->title; $All_Query = News::query()->paginate(8); diff --git a/app/Http/Requests/RequestPosition.php b/app/Http/Requests/RequestPosition.php new file mode 100644 index 0000000..43ecf72 --- /dev/null +++ b/app/Http/Requests/RequestPosition.php @@ -0,0 +1,52 @@ + [ + 'required', + 'string', + 'min:3', + 'max:255', + ], + 'sort' => [ + 'required', + 'numeric', + 'min:0', + 'max: 1000000' + ], + ]; + } + + public function messages() { + return [ + 'required' => 'Поле :attribute обязательно для ввода', + 'unique' => 'Поле :attribute должно быть уникальным', + 'mimes' => 'Допускаются файлы только с расширением jpeg,jpg,png', + 'numeric' => 'Поле :attribute должно быть числом', + 'min' => [ + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', + 'integer' => 'Поле «:attribute» должно быть :min или больше', + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + ], + + 'max' => [ + 'string' => 'Поле «:attribute» должно быть не больше :max символов', + 'integer' => 'Поле «:attribute» должно быть :max или меньше', + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + ], + + ]; + } +} diff --git a/app/Models/Job_title.php b/app/Models/Job_title.php index ff9bb38..b585bd5 100644 --- a/app/Models/Job_title.php +++ b/app/Models/Job_title.php @@ -13,6 +13,7 @@ class Job_title extends Model 'name', 'is_remove', 'parent_id', + 'sort' ]; /* * Связь модели Вакансии (Ad_employer) с моделью Должности (Job_title) diff --git a/app/Models/Positions.php b/app/Models/Positions.php new file mode 100644 index 0000000..35bac5b --- /dev/null +++ b/app/Models/Positions.php @@ -0,0 +1,16 @@ +id(); + $table->string('name', 255)->nullable(false); + $table->integer('sort')->default(100); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('positions'); + } +}; diff --git a/public/css/style45.css b/public/css/style45.css index 1a85cff..f580ac2 100644 --- a/public/css/style45.css +++ b/public/css/style45.css @@ -8909,4 +8909,22 @@ main + .news { display: -webkit-box; display: -ms-flexbox; display: flex; -} \ No newline at end of file +} + +.select2-selection--multiple .select2-selection__rendered { + display: -webkit-box !important; + display: -ms-flexbox !important; + display: flex !important; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + gap: 10px; + padding-top: 10px !important; + padding-bottom: 10px !important; +} + +.select2-selection--multiple .select2-selection__rendered .select2-selection__choice { + margin: 0; +} diff --git a/resources/views/admin/job_titles/form.blade.php b/resources/views/admin/job_titles/form.blade.php index c110d38..3ca5bd1 100644 --- a/resources/views/admin/job_titles/form.blade.php +++ b/resources/views/admin/job_titles/form.blade.php @@ -25,6 +25,20 @@
+
+
+ + Назад +
+
+ diff --git a/resources/views/admin/positions/position.blade.php b/resources/views/admin/positions/position.blade.php new file mode 100644 index 0000000..2a16160 --- /dev/null +++ b/resources/views/admin/positions/position.blade.php @@ -0,0 +1,80 @@ +@extends('layout.admin', ['title' => 'Админка - Работники']) +@section('script') + +@endsection + +@section('search') +@endsection + +@section('content') + +
+
+ Создать позицию

+ + + + + + + + + + + @foreach($Positions as $Pos) + + + + + + + @endforeach + +
ПозицияДата созданияИзменить
+ {{$Pos->id}} + + {{ $Pos->name }} + + {{ date('d.m.Y h:i:s', strtotime($Pos->created_at)) }} + + Изменить | + Удалить +
+
+
+@endsection diff --git a/resources/views/ajax/new_sky.blade.php b/resources/views/ajax/new_sky.blade.php index e090a25..fd815ba 100644 --- a/resources/views/ajax/new_sky.blade.php +++ b/resources/views/ajax/new_sky.blade.php @@ -1,12 +1,5 @@ -
- @include('block_real', ['flot' => $flot_paluba, 'title' => 'Палуба']) -
-
- @include('block_real', ['flot' => $flot_MO, 'title' => 'МО']) -
-
- @include('block_real', ['flot' => $flot_radovie, 'title' => 'Рядовые']) -
-
- @include('block_real', ['flot' => $flot_prochee, 'title' => 'Прочее']) -
+@foreach ($BigFlot as $key => $flot) +
+ @include('block_real', ['flot' => $flot, 'position' => $Position[$key]]) +
+@endforeach diff --git a/resources/views/block_real.blade.php b/resources/views/block_real.blade.php index 7da621c..b371924 100644 --- a/resources/views/block_real.blade.php +++ b/resources/views/block_real.blade.php @@ -5,7 +5,7 @@ @if ($flot->count()) @foreach ($flot as $key => $cat) @if ($k == 0) -
{{ $title }}
+
{{ $cat->position_ship }}
@endif @@ -21,7 +21,7 @@ @endphp @endforeach @else -
{{ $title }}
+
{{ $position->name }}
Тут нет информации diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 244014a..0cb1ec6 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -103,18 +103,13 @@ Скрыть -->
-
- @include('block_real', ['flot' => $flot_paluba, 'title' => 'Палуба']) -
-
- @include('block_real', ['flot' => $flot_MO, 'title' => 'МО']) -
-
- @include('block_real', ['flot' => $flot_radovie, 'title' => 'Рядовые']) -
-
- @include('block_real', ['flot' => $flot_prochee, 'title' => 'Прочее']) -
+ + @foreach ($BigFlot as $key => $flot) +
+ + @include('block_real', ['flot' => $flot, 'position' => $Position[$key]]) +
+ @endforeach
diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php index a4cd3ae..ea3ed8e 100644 --- a/resources/views/layout/admin.blade.php +++ b/resources/views/layout/admin.blade.php @@ -571,6 +571,9 @@ @endif @endif @endforeach +
  • + Позиция +
  • @@ -1227,6 +1230,16 @@ @endif @endif + + @if ($cont->url_page == "admin/position") + @if ((($cont->is_admin == 1) && ($admin == 1)) || + (($cont->is_manager == 1) && ($is_manager == 1))) +
  • + Позиция +
  • + @endif + @endif + @endforeach diff --git a/resources/views/new_sky.blade.php b/resources/views/new_sky.blade.php index 642e691..c7ab09d 100644 --- a/resources/views/new_sky.blade.php +++ b/resources/views/new_sky.blade.php @@ -69,18 +69,11 @@ Скрыть -->
    -
    - @include('block_real', ['flot' => $flot_paluba, 'title' => 'Палуба']) -
    -
    - @include('block_real', ['flot' => $flot_MO, 'title' => 'МО']) -
    -
    - @include('block_real', ['flot' => $flot_radovie, 'title' => 'Рядовые']) -
    -
    - @include('block_real', ['flot' => $flot_prochee, 'title' => 'Прочее']) -
    + @foreach ($BigFlot as $key => $flot) +
    + @include('block_real', ['flot' => $flot, 'position' => $Position[$key]]) +
    + @endforeach
    diff --git a/routes/web.php b/routes/web.php index f1bcbf1..6b20ca4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -289,6 +289,13 @@ Route::group([ // кабинет - список админов Route::get('group-admin', [AdminController::class, 'index'])->name('group-admin'); + // справочник Позиции + Route::get('positions', [AdminController::class, 'position'])->name('position'); + Route::get('positions/add', [AdminController::class, 'position_add'])->name('add-position'); + Route::post('positions/add', [AdminController::class, 'position_add_save'])->name('add-save-position'); + Route::get('positions/edit/{position}', [AdminController::class, 'position_edit'])->name('edit-position'); + Route::post('position/edit/{position}', [AdminController::class, 'position_update'])->name('update-position'); + Route::get('position/delete/{position}', [AdminController::class, 'position_delete'])->name('delete-position'); /////редактор////// кабинет - редактор сайта//////////////////////// Route::get('editor-site', function() {