First Commit
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use App\Models\Module;
|
||||
use Modules\Company\Models\Company;
|
||||
|
||||
class InsertSeoModule
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$moduleData = [
|
||||
'modules_name' => 'seo',
|
||||
'modules_display_name' => 'SEO Manager',
|
||||
'modules_description' => 'Gerenciamento de configurações globais de SEO, Sitemap e Robots.txt',
|
||||
'modules_version' => '1.0.0',
|
||||
'modules_author' => 'SysCMS Team',
|
||||
'modules_ative' => true,
|
||||
'modules_public' => true,
|
||||
'modules_blocked' => false,
|
||||
'modules_dependencies' => [],
|
||||
'modules_permissions' => [
|
||||
"seo.view",
|
||||
"seo.manage"
|
||||
],
|
||||
'modules_settings' => [
|
||||
"meta_title" => "SysCMS",
|
||||
"meta_description" => "",
|
||||
"meta_keywords" => "",
|
||||
"og_title" => "",
|
||||
"og_description" => "",
|
||||
"og_image" => "",
|
||||
"twitter_card" => "summary_large_image",
|
||||
"robots_txt" => "User-agent: *\nDisallow: /admin/\nAllow: /"
|
||||
],
|
||||
'modules_path' => 'modules/seo',
|
||||
'modules_namespace' => 'Modules\\Seo',
|
||||
'modules_icon' => 'bi bi-search',
|
||||
'menu_side_bar' => true,
|
||||
'menu_nav_bar' => false,
|
||||
'modules_order' => 90,
|
||||
'modules_install_date' => date('Y-m-d H:i:s'),
|
||||
'modules_update_date' => date('Y-m-d H:i:s')
|
||||
];
|
||||
|
||||
$existingModule = Module::where('modules_name', 'seo')->first();
|
||||
|
||||
if (!$existingModule) {
|
||||
$module = Module::create($moduleData);
|
||||
|
||||
if (Capsule::schema()->hasTable('bus')) {
|
||||
$companies = Company::all();
|
||||
foreach ($companies as $company) {
|
||||
$exists = Capsule::table('bus_modules')
|
||||
->where('bus_modules_bus_id', $company->bus_id)
|
||||
->where('bus_modules_module_id', $module->modules_id)
|
||||
->exists();
|
||||
|
||||
if (!$exists) {
|
||||
Capsule::table('bus_modules')->insert([
|
||||
'bus_modules_bus_id' => $company->bus_id,
|
||||
'bus_modules_module_id' => $module->modules_id,
|
||||
'bus_modules_is_enabled' => true,
|
||||
'bus_modules_settings' => json_encode([]),
|
||||
'bus_modules_enabled_by' => 1,
|
||||
'bus_modules_enabled_at' => date('Y-m-d H:i:s'),
|
||||
'bus_modules_show_public_nav' => true,
|
||||
'bus_modules_show_dashboard_nav' => true,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$module = Module::where('modules_name', 'seo')->first();
|
||||
if ($module) {
|
||||
Capsule::table('bus_modules')->where('bus_modules_module_id', $module->modules_id)->delete();
|
||||
$module->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
/**
|
||||
* Migration 002: Create seo_redirects table.
|
||||
*/
|
||||
class CreateSeoRedirectsTable
|
||||
{
|
||||
/**
|
||||
* Run the migration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (!Capsule::schema()->hasTable('seo_redirects')) {
|
||||
Capsule::schema()->create('seo_redirects', function ($table) {
|
||||
$table->increments('redirects_id');
|
||||
$table->string('redirects_from');
|
||||
$table->string('redirects_to');
|
||||
$table->integer('redirects_code')->default(301); // 301 (Permanent) or 302 (Temporary)
|
||||
$table->boolean('redirects_is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Capsule::schema()->dropIfExists('seo_redirects');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user