First Commit
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SysCMS - Content Management System
|
||||
*
|
||||
* Copyright (c) 2026 Marco Costa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Marco Costa
|
||||
* Email: contato@syspanel.com.br
|
||||
* Project: SysCMS
|
||||
*
|
||||
* This software is licensed, not sold.
|
||||
* Permission is granted to use this software
|
||||
* subject to the terms of the SysCMS Commercial License.
|
||||
*
|
||||
* Redistribution, sublicensing, resale, or
|
||||
* disclosure of this software, in whole or in part,
|
||||
* is strictly prohibited without prior written permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
/**
|
||||
* Migration: Insert Notes Module
|
||||
*/
|
||||
class InsertNotesModule
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$moduleName = 'notes';
|
||||
$moduleData = [
|
||||
'modules_name' => $moduleName,
|
||||
'modules_display_name' => 'Notes',
|
||||
'modules_description' => 'Módulo de notas e links para o usuário.',
|
||||
'modules_version' => '1.0.0',
|
||||
'modules_author' => 'SysCMS Team',
|
||||
'modules_ative' => 1,
|
||||
'modules_public' => 0,
|
||||
'modules_blocked' => 0,
|
||||
'modules_dependencies' => json_encode(['users']),
|
||||
'modules_permissions' => json_encode([
|
||||
"notes.view",
|
||||
"notes.create",
|
||||
"notes.edit",
|
||||
"notes.delete"
|
||||
]),
|
||||
'modules_settings' => json_encode([
|
||||
"menu" => [
|
||||
"dashboard" => [
|
||||
"icon" => "bi bi-sticky",
|
||||
"label" => "Notes",
|
||||
"route" => "admin/notes",
|
||||
"order" => 60,
|
||||
"permission" => "notes.view"
|
||||
]
|
||||
]
|
||||
]),
|
||||
'modules_path' => 'modules/notes',
|
||||
'modules_namespace' => 'Modules\\Notes',
|
||||
'modules_icon' => 'bi bi-sticky',
|
||||
'menu_side_bar' => 1,
|
||||
'menu_nav_bar' => 0,
|
||||
'modules_order' => 60,
|
||||
'modules_install_date' => date('Y-m-d H:i:s'),
|
||||
'modules_update_date' => date('Y-m-d H:i:s')
|
||||
];
|
||||
|
||||
$existingModule = Capsule::table('modules')->where('modules_name', $moduleName)->first();
|
||||
|
||||
if (!$existingModule) {
|
||||
$moduleId = Capsule::table('modules')->insertGetId($moduleData);
|
||||
|
||||
// Associate with all existing companies
|
||||
if (Capsule::schema()->hasTable('bus')) {
|
||||
$companies = Capsule::table('bus')->get();
|
||||
foreach ($companies as $company) {
|
||||
Capsule::table('bus_modules')->insert([
|
||||
'bus_modules_bus_id' => $company->bus_id,
|
||||
'bus_modules_module_id' => $moduleId,
|
||||
'bus_modules_is_enabled' => 1,
|
||||
'bus_modules_show_public_nav' => 0,
|
||||
'bus_modules_show_dashboard_nav' => 1,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$module = Capsule::table('modules')->where('modules_name', 'notes')->first();
|
||||
if ($module) {
|
||||
Capsule::table('bus_modules')->where('bus_modules_module_id', $module->modules_id)->delete();
|
||||
Capsule::table('modules')->where('modules_id', $module->modules_id)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SysCMS - Content Management System
|
||||
*
|
||||
* Copyright (c) 2026 Marco Costa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Marco Costa
|
||||
* Email: contato@syspanel.com.br
|
||||
* Project: SysCMS
|
||||
*
|
||||
* This software is licensed, not sold.
|
||||
* Permission is granted to use this software
|
||||
* subject to the terms of the SysCMS Commercial License.
|
||||
*
|
||||
* Redistribution, sublicensing, resale, or
|
||||
* disclosure of this software, in whole or in part,
|
||||
* is strictly prohibited without prior written permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Migration: Create Notes Table
|
||||
*/
|
||||
class CreateNotesTable
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (!Capsule::schema()->hasTable('notes')) {
|
||||
Capsule::schema()->create('notes', function (Blueprint $table) {
|
||||
$table->id('notes_id');
|
||||
$table->unsignedBigInteger('notes_idbus')->nullable();
|
||||
$table->unsignedBigInteger('notes_iduser')->nullable();
|
||||
$table->string('notes_title');
|
||||
$table->text('notes_content')->nullable();
|
||||
$table->enum('notes_type', ['note', 'link'])->default('note');
|
||||
$table->string('notes_url')->nullable();
|
||||
$table->boolean('notes_is_pinned')->default(false);
|
||||
$table->string('notes_color')->default('#ffffff');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('notes_idbus');
|
||||
$table->index('notes_iduser');
|
||||
$table->index('notes_type');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Capsule::schema()->dropIfExists('notes');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SysCMS - Content Management System
|
||||
*
|
||||
* Copyright (c) 2026 Marco Costa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Marco Costa
|
||||
* Email: contato@syspanel.com.br
|
||||
* Project: SysCMS
|
||||
*
|
||||
* This software is licensed, not sold.
|
||||
* Permission is granted to use this software
|
||||
* subject to the terms of the SysCMS Commercial License.
|
||||
*
|
||||
* Redistribution, sublicensing, resale, or
|
||||
* disclosure of this software, in whole or in part,
|
||||
* is strictly prohibited without prior written permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Migration: Add Category to Notes Table
|
||||
*/
|
||||
class AddCategoryToNotesTable
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (Capsule::schema()->hasTable('notes')) {
|
||||
Capsule::schema()->table('notes', function (Blueprint $table) {
|
||||
if (!Capsule::schema()->hasColumn('notes', 'notes_category')) {
|
||||
$table->string('notes_category')->nullable()->after('notes_type');
|
||||
$table->index('notes_category');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Capsule::schema()->hasTable('notes')) {
|
||||
Capsule::schema()->table('notes', function (Blueprint $table) {
|
||||
if (Capsule::schema()->hasColumn('notes', 'notes_category')) {
|
||||
$table->dropColumn('notes_category');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SysCMS - Content Management System
|
||||
*
|
||||
* Copyright (c) 2026 Marco Costa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Marco Costa
|
||||
* Email: contato@syspanel.com.br
|
||||
* Project: SysCMS
|
||||
*
|
||||
* This software is licensed, not sold.
|
||||
* Permission is granted to use this software
|
||||
* subject to the terms of the SysCMS Commercial License.
|
||||
*
|
||||
* Redistribution, sublicensing, resale, or
|
||||
* disclosure of this software, in whole or in part,
|
||||
* is strictly prohibited without prior written permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Migration: Create Notes Subjects Table and Update Notes Table
|
||||
*/
|
||||
class CreateNotesSubjectsTable
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Create subjects table
|
||||
if (!Capsule::schema()->hasTable('notes_subjects')) {
|
||||
Capsule::schema()->create('notes_subjects', function (Blueprint $table) {
|
||||
$table->id('subjects_id');
|
||||
$table->unsignedBigInteger('subjects_idbus')->nullable();
|
||||
$table->unsignedBigInteger('subjects_iduser')->nullable();
|
||||
$table->string('subjects_name');
|
||||
$table->string('subjects_color')->default('#6c757d');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('subjects_idbus');
|
||||
$table->index('subjects_iduser');
|
||||
});
|
||||
}
|
||||
|
||||
// Update notes table to use subject_id
|
||||
if (Capsule::schema()->hasTable('notes')) {
|
||||
Capsule::schema()->table('notes', function (Blueprint $table) {
|
||||
if (!Capsule::schema()->hasColumn('notes', 'notes_subject_id')) {
|
||||
$table->unsignedBigInteger('notes_subject_id')->nullable()->after('notes_type');
|
||||
$table->index('notes_subject_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Capsule::schema()->hasTable('notes')) {
|
||||
Capsule::schema()->table('notes', function (Blueprint $table) {
|
||||
if (Capsule::schema()->hasColumn('notes', 'notes_subject_id')) {
|
||||
$table->dropColumn('notes_subject_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Capsule::schema()->dropIfExists('notes_subjects');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Migration: Remove Link columns from Notes
|
||||
*/
|
||||
class RemoveLinkColumnsFromNotes
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (Capsule::schema()->hasColumn('notes', 'notes_type')) {
|
||||
Capsule::schema()->table('notes', function (Blueprint $table) {
|
||||
$table->dropColumn('notes_type');
|
||||
});
|
||||
}
|
||||
|
||||
if (Capsule::schema()->hasColumn('notes', 'notes_url')) {
|
||||
Capsule::schema()->table('notes', function (Blueprint $table) {
|
||||
$table->dropColumn('notes_url');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Capsule::schema()->table('notes', function (Blueprint $table) {
|
||||
$table->enum('notes_type', ['note', 'link'])->default('note')->after('notes_content');
|
||||
$table->string('notes_url')->nullable()->after('notes_type');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
/**
|
||||
* Migration 006: Add attachments to notes table.
|
||||
*
|
||||
* This migration adds columns for images and files to the notes table.
|
||||
*/
|
||||
class AddAttachmentsToNotes
|
||||
{
|
||||
/**
|
||||
* Run the migration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Capsule::schema()->hasTable('notes')) {
|
||||
Capsule::schema()->table('notes', function ($table) {
|
||||
if (!Capsule::schema()->hasColumn('notes', 'notes_image')) {
|
||||
$table->string('notes_image')->nullable()->after('notes_color');
|
||||
}
|
||||
if (!Capsule::schema()->hasColumn('notes', 'notes_file')) {
|
||||
$table->string('notes_file')->nullable()->after('notes_image');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
if (Capsule::schema()->hasTable('notes')) {
|
||||
Capsule::schema()->table('notes', function ($table) {
|
||||
if (Capsule::schema()->hasColumn('notes', 'notes_image')) {
|
||||
$table->dropColumn('notes_image');
|
||||
}
|
||||
if (Capsule::schema()->hasColumn('notes', 'notes_file')) {
|
||||
$table->dropColumn('notes_file');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user