diff --git a/app/Enums/EnumTraits/EnumToArray.php b/app/Enums/EnumTraits/EnumToArray.php new file mode 100644 index 0000000..9c37688 --- /dev/null +++ b/app/Enums/EnumTraits/EnumToArray.php @@ -0,0 +1,11 @@ +whereIn('name', $block_names) + ->get() + ->keyBy('name') + ->toArray(); + return view('admin.counters_main.index', compact('block_names', 'blocks')); + } + + public function counters_main_update(Request $request, string $name) { + PageContent::updateOrCreate( + ['name' => $name], + array_merge(['name' => $name], $request->all()) + ); + $block_names = MainPageCounters::values();; + $blocks = PageContent::select('name', 'title', 'description', 'extra') + ->whereIn('name', $block_names) + ->get() + ->keyBy('name') + ->toArray(); + return view('admin.counters_main.index', compact('block_names', 'blocks')); + } + //////////////////////////////////////////////////////////////////////////////// // кабинет - редактор шапки-футера сайта public function editblocks(Request $request) { diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 38f21d5..1c67f58 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -10,7 +10,6 @@ use App\Models\Ad_employer; use App\Models\Ad_jobs; use App\Models\Category; use App\Models\Education; -use App\Models\Employer; use App\Models\employers_main; use App\Models\Job_title; use App\Models\Like_vacancy; @@ -25,7 +24,8 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Validator; -use App\Classes\StatusUser; +use App\Models\PageContent; +use App\Enums\MainPageCounters; class MainController extends Controller { @@ -96,7 +96,16 @@ class MainController extends Controller })-> orderBy('sort')->get(); $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); - return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job')); + + $block_names = MainPageCounters::values();; + $blocks_counters = PageContent::select('name', 'title', 'description', 'extra') + ->whereIn('name', $block_names) + ->orderBy('name', 'asc') + ->get() + ->keyBy('name') + ->toArray(); + + return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job', 'blocks_counters')); } public function search_vacancies(Request $request) { diff --git a/app/Models/PageContent.php b/app/Models/PageContent.php new file mode 100644 index 0000000..86386a2 --- /dev/null +++ b/app/Models/PageContent.php @@ -0,0 +1,18 @@ + '', 'prefix_indexes' => true, 'strict' => true, - 'engine' => null, + 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], diff --git a/database/migrations/2024_06_18_110133_create_page_contents_table.php b/database/migrations/2024_06_18_110133_create_page_contents_table.php new file mode 100644 index 0000000..28eb6c2 --- /dev/null +++ b/database/migrations/2024_06_18_110133_create_page_contents_table.php @@ -0,0 +1,35 @@ +id(); + $table->string('name')->unique(); + $table->string('title'); + $table->string('description'); + $table->string('extra'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('page_contents'); + } +}; diff --git a/resources/views/TITLE_TEXT.blade.php b/resources/views/TITLE_TEXT.blade.php deleted file mode 100644 index 83ecec1..0000000 --- a/resources/views/TITLE_TEXT.blade.php +++ /dev/null @@ -1,18 +0,0 @@ -