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 @@
+
+