feat: add initial database schema migration for project core tables

This commit is contained in:
Ümit Tunç
2026-04-28 21:34:44 +03:00
parent 172edd282d
commit 7dfb13ffac
9 changed files with 599 additions and 987 deletions
@@ -0,0 +1,599 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Table: contents
if (!Schema::hasTable('contents')) {
DB::statement("
CREATE TABLE `contents` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`slug` varchar(180) DEFAULT NULL,
`title` varchar(180) DEFAULT NULL,
`type` varchar(180) DEFAULT NULL,
`alt_type` varchar(180) DEFAULT NULL,
`cover` varchar(180) DEFAULT NULL,
`files` longtext DEFAULT NULL,
`uid` varchar(180) DEFAULT NULL,
`html` longtext DEFAULT NULL,
`json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`kid` varchar(180) DEFAULT NULL,
`s` int(11) DEFAULT NULL,
`tkid` text DEFAULT NULL,
`deleted_at` varchar(180) DEFAULT NULL,
`y` int(11) DEFAULT 0,
`breadcrumb` text DEFAULT NULL,
`fields` text DEFAULT NULL,
`max` float(255,2) DEFAULT NULL,
`min` float(255,2) DEFAULT NULL,
`date` date DEFAULT NULL,
`time1` time DEFAULT NULL,
`time2` time DEFAULT NULL,
`title2` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`datetime1` datetime DEFAULT NULL,
`datetime2` datetime DEFAULT NULL,
`vd` varchar(255) DEFAULT NULL,
`vn` varchar(255) DEFAULT NULL,
`adres` text DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=555 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: counters
if (!Schema::hasTable('counters')) {
DB::statement("
CREATE TABLE `counters` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`prefix` varchar(100) DEFAULT NULL,
`value` int(11) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: document_history
if (!Schema::hasTable('document_history')) {
DB::statement("
CREATE TABLE `document_history` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`table_name` varchar(255) DEFAULT NULL,
`column_name` varchar(255) DEFAULT NULL,
`row_id` bigint(20) unsigned DEFAULT NULL,
`user_name` varchar(255) DEFAULT NULL,
`action` varchar(255) NOT NULL,
`file_name` varchar(255) NOT NULL,
`file_size` varchar(255) DEFAULT NULL,
`moved_from` varchar(255) DEFAULT NULL,
`moved_to` varchar(255) DEFAULT NULL,
`action_date` timestamp NOT NULL,
`file_path` text NOT NULL,
`notes` text DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `document_history_table_name_column_name_row_id_index` (`table_name`,`column_name`,`row_id`),
KEY `document_history_file_name_table_name_index` (`file_name`,`table_name`)
) ENGINE=InnoDB AUTO_INCREMENT=64182 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: document_manager_permissions
if (!Schema::hasTable('document_manager_permissions')) {
DB::statement("
CREATE TABLE `document_manager_permissions` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_level` varchar(255) NOT NULL,
`folder_path` varchar(500) NOT NULL,
`permission_type` enum('read','write','edit') NOT NULL,
`is_allowed` tinyint(1) NOT NULL DEFAULT 0,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_permission` (`user_level`,`folder_path`,`permission_type`),
KEY `document_manager_permissions_user_level_index` (`user_level`),
KEY `document_manager_permissions_folder_path_index` (`folder_path`),
KEY `document_manager_permissions_permission_type_index` (`permission_type`),
KEY `document_manager_permissions_user_level_permission_type_index` (`user_level`,`permission_type`)
) ENGINE=InnoDB AUTO_INCREMENT=2058 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: document_revisions
if (!Schema::hasTable('document_revisions')) {
DB::statement("
CREATE TABLE `document_revisions` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`transmittal_document` varchar(100) DEFAULT NULL,
`publish_date` date DEFAULT NULL,
`zone` varchar(100) DEFAULT NULL,
`subcontructer` varchar(100) DEFAULT NULL,
`area` varchar(100) DEFAULT NULL,
`drawing_no` varchar(100) DEFAULT NULL,
`line_number` varchar(255) DEFAULT NULL,
`revision_no` varchar(100) DEFAULT NULL,
`remarks` varchar(100) DEFAULT NULL,
`pdf_engineering` text DEFAULT NULL,
`pdf_spool_iso` text DEFAULT NULL,
`pdf_as_build` text DEFAULT NULL,
`document_name` varchar(255) NOT NULL,
`working_documentation` varchar(100) DEFAULT NULL,
`axonometry` varchar(100) DEFAULT NULL,
`discipline` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_dr_line_number` (`line_number`)
) ENGINE=InnoDB AUTO_INCREMENT=3104 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: document_templates
if (!Schema::hasTable('document_templates')) {
DB::statement("
CREATE TABLE `document_templates` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`slug` varchar(180) DEFAULT NULL,
`title` varchar(180) DEFAULT NULL,
`type` varchar(180) DEFAULT NULL,
`alt_type` varchar(180) DEFAULT NULL,
`cover` varchar(180) DEFAULT NULL,
`files` longtext DEFAULT NULL,
`excel_analysis` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`uid` varchar(180) DEFAULT NULL,
`html` longtext DEFAULT NULL,
`json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`kid` varchar(180) DEFAULT NULL,
`s` int(11) DEFAULT NULL,
`tkid` text DEFAULT NULL,
`deleted_at` varchar(180) DEFAULT NULL,
`y` int(11) DEFAULT 0,
`breadcrumb` text DEFAULT NULL,
`fields` text DEFAULT NULL,
`max` float(255,2) DEFAULT NULL,
`min` float(255,2) DEFAULT NULL,
`date` date DEFAULT NULL,
`time1` time DEFAULT NULL,
`time2` time DEFAULT NULL,
`title2` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`datetime1` datetime DEFAULT NULL,
`datetime2` datetime DEFAULT NULL,
`vd` varchar(255) DEFAULT NULL,
`vn` varchar(255) DEFAULT NULL,
`adres` text DEFAULT NULL,
`lang` varchar(255) NOT NULL DEFAULT 'en',
`title3` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `document_templates_chk_1` CHECK (json_valid(`excel_analysis`))
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: failed_jobs (Laravel best practice)
if (!Schema::hasTable('failed_jobs')) {
DB::statement("
CREATE TABLE `failed_jobs` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`uuid` varchar(255) NOT NULL,
`connection` text NOT NULL,
`queue` text NOT NULL,
`payload` longtext NOT NULL,
`exception` longtext NOT NULL,
`failed_at` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`)
) ENGINE=InnoDB AUTO_INCREMENT=16126 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: fields
if (!Schema::hasTable('fields')) {
DB::statement("
CREATE TABLE `fields` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`type` varchar(180) NOT NULL,
`title` varchar(180) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`input_type` varchar(180) DEFAULT '' COMMENT 'input type',
`values` text DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: job_batches (Laravel best practice)
if (!Schema::hasTable('job_batches')) {
DB::statement("
CREATE TABLE `job_batches` (
`id` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`total_jobs` int(11) NOT NULL,
`pending_jobs` int(11) NOT NULL,
`failed_jobs` int(11) NOT NULL,
`failed_job_ids` longtext NOT NULL,
`options` mediumtext DEFAULT NULL,
`cancelled_at` int(11) DEFAULT NULL,
`created_at` int(11) NOT NULL,
`finished_at` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: job_descriptions
if (!Schema::hasTable('job_descriptions')) {
DB::statement("
CREATE TABLE `job_descriptions` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: jobs (Laravel best practice)
if (!Schema::hasTable('jobs')) {
DB::statement("
CREATE TABLE `jobs` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`queue` varchar(255) NOT NULL,
`payload` longtext NOT NULL,
`attempts` tinyint(3) unsigned NOT NULL,
`reserved_at` int(10) unsigned DEFAULT NULL,
`available_at` int(10) unsigned NOT NULL,
`created_at` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `jobs_queue_index` (`queue`)
) ENGINE=InnoDB AUTO_INCREMENT=1348345 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: mail_templates
if (!Schema::hasTable('mail_templates')) {
DB::statement("
CREATE TABLE `mail_templates` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`slug` varchar(180) DEFAULT NULL,
`title` varchar(180) DEFAULT NULL,
`type` varchar(180) DEFAULT NULL,
`alt_type` varchar(180) DEFAULT NULL,
`cover` varchar(180) DEFAULT NULL,
`files` longtext DEFAULT NULL,
`uid` varchar(180) DEFAULT NULL,
`html` longtext DEFAULT NULL,
`json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`kid` varchar(180) DEFAULT NULL,
`s` int(11) DEFAULT NULL,
`tkid` text DEFAULT NULL,
`deleted_at` varchar(180) DEFAULT NULL,
`y` int(11) DEFAULT 0,
`breadcrumb` text DEFAULT NULL,
`fields` text DEFAULT NULL,
`max` float(255,2) DEFAULT NULL,
`min` float(255,2) DEFAULT NULL,
`date` date DEFAULT NULL,
`time1` time DEFAULT NULL,
`time2` time DEFAULT NULL,
`title2` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`datetime1` datetime DEFAULT NULL,
`datetime2` datetime DEFAULT NULL,
`vd` varchar(255) DEFAULT NULL,
`vn` varchar(255) DEFAULT NULL,
`adres` text DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: mailgun_logs
if (!Schema::hasTable('mailgun_logs')) {
DB::statement("
CREATE TABLE `mailgun_logs` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`slug` varchar(180) DEFAULT NULL,
`title` varchar(180) DEFAULT NULL,
`type` varchar(180) DEFAULT NULL,
`alt_type` varchar(180) DEFAULT NULL,
`cover` varchar(180) DEFAULT NULL,
`files` longtext DEFAULT NULL,
`uid` varchar(180) DEFAULT NULL,
`html` longtext DEFAULT NULL,
`json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`kid` varchar(180) DEFAULT NULL,
`s` int(11) DEFAULT NULL,
`tkid` text DEFAULT NULL,
`deleted_at` varchar(180) DEFAULT NULL,
`y` int(11) DEFAULT 0,
`breadcrumb` text DEFAULT NULL,
`fields` text DEFAULT NULL,
`max` float(255,2) DEFAULT NULL,
`min` float(255,2) DEFAULT NULL,
`date` date DEFAULT NULL,
`time1` time DEFAULT NULL,
`time2` time DEFAULT NULL,
`title2` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`datetime1` datetime DEFAULT NULL,
`datetime2` datetime DEFAULT NULL,
`vd` varchar(255) DEFAULT NULL,
`vn` varchar(255) DEFAULT NULL,
`adres` text DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: notifications
if (!Schema::hasTable('notifications')) {
DB::statement("
CREATE TABLE `notifications` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) unsigned NOT NULL,
`notification_code` varchar(255) NOT NULL,
`title` varchar(255) NOT NULL,
`message` text NOT NULL,
`link` varchar(255) DEFAULT NULL,
`filter_params` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`filter_params`)),
`is_read` tinyint(1) NOT NULL DEFAULT 0,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `notifications_user_id_is_read_index` (`user_id`,`is_read`),
KEY `notifications_notification_code_index` (`notification_code`),
KEY `notifications_created_at_index` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=86368 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: personal_access_tokens (Laravel best practice)
if (!Schema::hasTable('personal_access_tokens')) {
DB::statement("
CREATE TABLE `personal_access_tokens` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`tokenable_type` varchar(255) NOT NULL,
`tokenable_id` bigint(20) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`token` varchar(64) NOT NULL,
`abilities` text DEFAULT NULL,
`last_used_at` timestamp NULL DEFAULT NULL,
`expires_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2905 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: rows
if (!Schema::hasTable('rows')) {
DB::statement("
CREATE TABLE `rows` (
`id` bigint(20) unsigned NOT NULL,
`type` varchar(255) NOT NULL,
`title` varchar(255) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
");
}
// Table: settings
if (!Schema::hasTable('settings')) {
DB::statement("
CREATE TABLE `settings` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`slug` varchar(180) DEFAULT NULL,
`title` varchar(180) DEFAULT NULL,
`type` varchar(180) DEFAULT NULL,
`alt_type` varchar(180) DEFAULT NULL,
`cover` varchar(180) DEFAULT NULL,
`files` longtext DEFAULT NULL,
`uid` varchar(180) DEFAULT NULL,
`html` longtext DEFAULT NULL,
`json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`kid` varchar(180) DEFAULT NULL,
`s` int(11) DEFAULT NULL,
`tkid` text DEFAULT NULL,
`deleted_at` varchar(180) DEFAULT NULL,
`y` int(11) DEFAULT 0,
`breadcrumb` text DEFAULT NULL,
`fields` text DEFAULT NULL,
`max` float(255,2) DEFAULT NULL,
`min` float(255,2) DEFAULT NULL,
`date` date DEFAULT NULL,
`time1` time DEFAULT NULL,
`time2` time DEFAULT NULL,
`title2` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`datetime1` datetime DEFAULT NULL,
`datetime2` datetime DEFAULT NULL,
`vd` varchar(255) DEFAULT NULL,
`vn` varchar(255) DEFAULT NULL,
`adres` text DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2987 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: translate
if (!Schema::hasTable('translate')) {
DB::statement("
CREATE TABLE `translate` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`icerik` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_turkish_ci DEFAULT NULL,
`ceviri` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_turkish_ci DEFAULT NULL,
`dil` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6117 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
");
}
// Table: types
if (!Schema::hasTable('types')) {
DB::statement("
CREATE TABLE `types` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(180) NOT NULL,
`fields` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`slug` varchar(180) DEFAULT NULL,
`icon` varchar(180) DEFAULT NULL,
`kid` varchar(255) DEFAULT NULL,
`s` int(11) DEFAULT NULL,
`full_control` varchar(255) DEFAULT NULL,
`write` varchar(255) DEFAULT NULL,
`read` varchar(255) DEFAULT NULL,
`modify` varchar(255) DEFAULT NULL,
`enabled` tinyint(1) NOT NULL DEFAULT 1,
`is_mobile` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=187 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: user_levels
if (!Schema::hasTable('user_levels')) {
DB::statement("
CREATE TABLE `user_levels` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`title` varchar(100) DEFAULT NULL,
`level_index` int(11) NOT NULL,
`full_control` int(11) NOT NULL,
`write` int(11) NOT NULL,
`read` int(11) NOT NULL,
`modify` int(11) NOT NULL,
`description` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: users (Laravel best practice - including custom fields)
if (!Schema::hasTable('users')) {
DB::statement("
CREATE TABLE `users` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`registration_no` varchar(255) DEFAULT NULL,
`name` varchar(180) DEFAULT NULL,
`name_ru` varchar(255) DEFAULT NULL,
`father_name` varchar(255) DEFAULT NULL,
`level` varchar(255) DEFAULT 'User',
`slug` varchar(180) DEFAULT NULL,
`json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`phone` varchar(180) DEFAULT NULL,
`email` varchar(180) DEFAULT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(180) NOT NULL,
`remember_token` varchar(100) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`pic` varchar(180) DEFAULT NULL,
`permissions` text DEFAULT NULL,
`recover` varchar(180) DEFAULT NULL,
`country` varchar(255) DEFAULT NULL,
`last_seen` datetime DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`ust` varchar(255) DEFAULT NULL,
`uid` varchar(255) DEFAULT NULL,
`note` text DEFAULT NULL,
`date_of_birth` date DEFAULT NULL,
`experience` int(11) DEFAULT NULL,
`qualitification` int(11) DEFAULT NULL,
`gender` varchar(255) DEFAULT NULL,
`job_name` varchar(255) DEFAULT NULL,
`passport_no` varchar(255) DEFAULT NULL,
`subcontructer` varchar(255) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL,
`date_start` date DEFAULT NULL,
`date_finish` date DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=491 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
// Table: values
if (!Schema::hasTable('values')) {
DB::statement("
CREATE TABLE `values` (
`id` bigint(20) unsigned NOT NULL,
`row` varchar(180) NOT NULL,
`titles` text NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// For an initialization migration, down usually drops the tables, but we follow the 'if exists' rule
Schema::dropIfExists('annotations');
Schema::dropIfExists('contents');
Schema::dropIfExists('counters');
Schema::dropIfExists('document_history');
Schema::dropIfExists('document_manager_permissions');
Schema::dropIfExists('document_revisions');
Schema::dropIfExists('document_templates');
Schema::dropIfExists('failed_jobs');
Schema::dropIfExists('fields');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('job_descriptions');
Schema::dropIfExists('jobs');
Schema::dropIfExists('mail_templates');
Schema::dropIfExists('mailgun_logs');
Schema::dropIfExists('notifications');
Schema::dropIfExists('personal_access_tokens');
Schema::dropIfExists('rows');
Schema::dropIfExists('settings');
Schema::dropIfExists('translate');
Schema::dropIfExists('types');
Schema::dropIfExists('user_levels');
Schema::dropIfExists('users');
Schema::dropIfExists('values');
}
};
-23
View File
@@ -1,23 +0,0 @@
<?php
$email = post("email");
$password = post("password");
if (Auth::attempt(array('email' => $email, 'password' => $password))){
// echo "Kullanıcı girişiniz başarılı. \n";
} else {
print2($_POST);
echo "Kullanıcı adı veya şifreniz yanlış. Lütfen tekrar deneyiniz. \n";
exit();
}
if(getisset("route")) {
$route = get("route");
?>
@if(View::exists("api.$route"))
@include("api.$route")
@else
Geçerli bir yönlendirici bulunamadı
@endif
<?php
} ?>
-93
View File
@@ -1,93 +0,0 @@
<?php
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
set_time_limit(-1);
ini_set('max_execution_time', -1);
$cronjobDocumentsPeriod = setting('cron_job_period');
$oneMinuteAgo = Carbon::now()->subMinutes($cronjobDocumentsPeriod);
$take = setting('cron_job_batch_process_count');
$saat = date("H:i");
if(!getesit("type","")) {
Cache::forget("cronjobDocuments");
}
if(!getisset("type"))
{
exit();
}
if($saat == "00:00")
{
Cache::forget("cronjob");
dump("forget cronjobDocuments");
}
if(!Cache::has("cronjobDocuments")) {
$start = new Carbon(simdi());
Cache::put("cronjobDocuments", simdi());
Log::debug("🟢📂 cron document start: " . simdi());
$allFiles = glob(base_path() . '/resources/views/cron-documents/*.blade.php');
$total = count($allFiles);
$count = 0;
try {
?>
@if(!getesit("type",""))
@includeIf('cron-documents.' . get("type"))
@else
@foreach ($allFiles as $file)
<?php
$description = $file;
$description = str_replace(".blade.php", "", $description);
Cache::put("cronjob_document_progress", [
'total' => $total,
'count' => $count,
'progress' => round($count * 100 / $total),
'description' => $description,
'start' => simdi()
]);
$count++;
?>
@include('cron-documents.' . basename(str_replace('.blade.php', '', $file)))
@endforeach
@endif
<?php
} catch (\Throwable $th) {
//throw $th;
dump($th);
Log::error("cron documents");
Log::error($th->getMessage());
Cache::forget("cronjobDocuments");
}
?>
<?php
$end = new Carbon(simdi());
Cache::put("cronjob_document_progress", [
'total' => $total,
'count' => $total,
'progress' => 100,
'description' => "finish " . simdi() . " " . $start->diff($end)->format('%H:%I:%S')
]);
Log::debug("🔴📂 cron document finish: " . simdi());
Log::debug("⏰📂 süre: " . $start->diff($end)->format('%H:%I:%S'));
Cache::forget("cronjobDocuments");
} else {
dump("Çalışan bir cron var onun bitmesini bekliyorum");
Log::debug("Çalışan bir cron documents var onun bitmesini bekliyorum");
}
@@ -1,116 +0,0 @@
<?php
if(!Cache::has("register-creator-cronjob")) {
Cache::put("register-creator-cronjob", simdi());
$queue = Cache::get("register-creator-queue");
if(!is_null($queue)) {
dump("Register Creator başladı");
foreach($queue AS $queueId => &$data) {
try {
$_POST = $data;
?>
@include("admin-ajax.pdf.register-creator")
<?php
$subject = "$queueId Register Creator Job Completed!";
$body = "Dear {$data['user']->name} {$data['user']->surname},
$queueId register creator job has been completed.
";
} catch (\Throwable $th) {
$subject = "$queueId Register Creator Job Not Completed!";
$body = "Dear {$data['user']->name} {$data['user']->surname},
$queueId register creator job not completed. Error detail there 👇
{$th->getMessage()}
";
Log::error($body);
dump($body);
}
mailSend($data['user']->email, $subject, $body);
$lastQueue = Cache::get("register-creator-queue");
unset($lastQueue[$queueId]);
Cache::put("register-creator-queue", $lastQueue);
}
//dump("Register Creator bitti");
} else {
//dump("Register Creator işi yok bekliyorum...");
}
Cache::forget("register-creator-cronjob");
} else {
dump("Register Creator Job çalışıyor bitmesini bekliyorum");
dump(Cache::get("register-creator-cronjob"));
}
if(!Cache::has("tp-creator-cronjob")) {
Cache::put("tp-creator-cronjob", simdi());
$queue = Cache::get("tp-creator-queue");
if(!is_null($queue)) {
dump("Register Creator başladı");
foreach($queue AS $queueId => &$data) {
try {
$_POST = $data;
?>
@include("admin-ajax.pdf.tp-register-creator")
<?php
$subject = "$queueId Register Creator Job Completed!";
$body = "Dear {$data['user']->name} {$data['user']->surname},
$queueId register creator job has been completed.
";
} catch (\Throwable $th) {
$subject = "$queueId Register Creator Job Not Completed!";
$body = "Dear {$data['user']->name} {$data['user']->surname},
$queueId register creator job not completed. Error detail there 👇
{$th->getMessage()}
";
Log::error($body);
dump($body);
}
mailSend($data['user']->email, $subject, $body);
$lastQueue = Cache::get("tp-creator-queue");
unset($lastQueue[$queueId]);
Cache::put("tp-creator-queue", $lastQueue);
}
dump("Register Creator bitti");
} else {
dump("Register Creator işi yok bekliyorum...");
}
Cache::forget("tp-creator-cronjob");
} else {
dump("Register Creator Job çalışıyor bitmesini bekliyorum");
dump(Cache::get("tp-creator-cronjob"));
}
?>
@@ -1,373 +0,0 @@
<?php
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\DB;
// Memory ve execution limitleri
$maxExecutionTime = 60; // 60 saniye
$maxMemoryLimit = 256 * 1024 * 1024; // 256 MB memory limit
$startTime = time();
$initialMemory = memory_get_usage(true);
// Memory limit ayarla
ini_set('memory_limit', '256M');
ini_set('max_execution_time', $maxExecutionTime);
Log::debug("=== CRON REPORT BUILDER QUEUE STARTED ===");
Log::debug("Timestamp: " . date('Y-m-d H:i:s'));
Log::debug("Initial memory usage: " . round($initialMemory / 1024 / 1024, 2) . " MB");
Log::debug("Memory limit set to: " . round($maxMemoryLimit / 1024 / 1024, 2) . " MB");
// Memory kontrol fonksiyonu
function checkMemoryLimit($startMemory, $maxLimit) {
$currentMemory = memory_get_usage(true);
$memoryUsed = $currentMemory - $startMemory;
$memoryPercentage = ($memoryUsed / $maxLimit) * 100;
Log::debug("Memory usage: " . round($currentMemory / 1024 / 1024, 2) . " MB");
Log::debug("Memory used since start: " . round($memoryUsed / 1024 / 1024, 2) . " MB");
Log::debug("Memory usage percentage: " . round($memoryPercentage, 2) . "%");
if ($memoryUsed > $maxLimit) {
Log::debug("⚠ CRITICAL: Memory limit exceeded! Stopping execution.");
return false;
}
if ($memoryPercentage > 80) {
Log::debug("⚠ WARNING: Memory usage is high (" . round($memoryPercentage, 2) . "%)");
}
return true;
}
// Database bağlantısını yenileme fonksiyonu
function refreshDatabaseConnection() {
try {
DB::disconnect();
DB::reconnect();
Log::debug("🔄 Database connection refreshed");
} catch (Exception $e) {
Log::debug("❌ Failed to refresh database connection: " . $e->getMessage());
}
}
// Memory temizleme fonksiyonu
function cleanupMemory() {
// Tüm değişkenleri temizle
unset($GLOBALS['_POST']);
unset($GLOBALS['_GET']);
unset($GLOBALS['_REQUEST']);
// Garbage collection'ı zorla
gc_collect_cycles();
// Memory kullanımını kontrol et
$currentMemory = memory_get_usage(true);
Log::debug("🧹 Memory cleanup completed. Current usage: " . round($currentMemory / 1024 / 1024, 2) . " MB");
}
// İlk database bağlantısını kur
refreshDatabaseConnection();
$documentTemplates = DB::table("document_templates")->where("y", "1")->orderByRaw('RAND()')->get();
Log::debug("Total document templates found: " . $documentTemplates->count());
// Her template için progress takibi
$templateProgress = [];
foreach ($documentTemplates as $documentTemplate) {
$templateId = $documentTemplate->id;
$cacheKey = "cron_report_builder_template_{$templateId}";
$progressCacheKey = "cron_report_builder_progress_{$templateId}";
$lastProcessedIndex = (int)setting($cacheKey, false, "0");
$progressJson = setting($progressCacheKey, false, '{"processed_count":0,"error_count":0,"success_count":0,"total_records":0}');
$progress = json_decode($progressJson, true);
$templateProgress[$templateId] = [
'cacheKey' => $cacheKey,
'progressCacheKey' => $progressCacheKey,
'lastProcessedIndex' => $lastProcessedIndex,
'progress' => $progress
];
}
$maxRecordsPerRun = 1; // Her çalıştırmada her template için maksimum 1 kayıt işle (azaltıldı)
$totalProcessedInThisRun = 0;
$databaseRefreshCounter = 0;
// Ana döngü - template'ler arasında dönüşümlü olarak ilerle
while (true) {
// Maksimum çalışma süresini kontrol et
if ((time() - $startTime) >= $maxExecutionTime) {
Log::debug("⚠ Maximum execution time ({$maxExecutionTime}s) reached. Stopping execution.");
break;
}
// Memory kontrolü
if (!checkMemoryLimit($initialMemory, $maxMemoryLimit)) {
break;
}
$activeTemplates = 0;
// Her template için bir kayıt işle
foreach ($documentTemplates as $documentTemplate) {
$templateId = $documentTemplate->id;
// Bu template için progress bilgilerini al
$progressInfo = $templateProgress[$templateId];
$cacheKey = $progressInfo['cacheKey'];
$progressCacheKey = $progressInfo['progressCacheKey'];
$lastProcessedIndex = $progressInfo['lastProcessedIndex'];
$progress = $progressInfo['progress'];
Log::debug("--- Processing Template ID: {$templateId} ---");
Log::debug("Template Name: " . ($documentTemplate->title ?? 'N/A'));
$fields = json_decode($documentTemplate->fields);
if(isset($fields->editorMaster)) {
Log::debug("✓ Editor Master SQL found");
if(isset($fields->multipleMode)) {
Log::debug("⚠ Multiple Mode detected - skipping this template");
continue;
}
// Master query'yi çalıştır - Database bağlantısını kontrol et
try {
// Log::debug("Executing Master SQL: " . $fields->editorMaster);
$resultMaster = DB::select($fields->editorMaster);
// Log::debug("Master query returned " . count($resultMaster) . " records");
} catch (Exception $e) {
Log::debug("❌ Database error in master query: " . $e->getMessage());
refreshDatabaseConnection();
continue;
}
// Total records'u güncelle (ilk kez çalıştırılıyorsa)
if ($progress['total_records'] == 0) {
$progress['total_records'] = count($resultMaster);
$templateProgress[$templateId]['progress'] = $progress;
}
// Bu template tamamlanmış mı kontrol et
if ($lastProcessedIndex >= count($resultMaster)) {
Log::debug("🎉 Template ID: {$templateId} already completed!");
unset($resultMaster);
continue;
}
$activeTemplates++;
if(isset($fields->editorDetail) && !empty($resultMaster)) {
Log::debug("✓ Editor Detail SQL found and master results exist");
// Bu template için kaç kayıt işleyeceğimizi hesapla
$recordsToProcess = min($maxRecordsPerRun, count($resultMaster) - $lastProcessedIndex);
Log::debug("📈 Processing {$recordsToProcess} records for template {$templateId}");
$processedCount = $progress['processed_count'];
$errorCount = $progress['error_count'];
$successCount = $progress['success_count'];
// Bu template için kayıtları işle
for($i = 0; $i < $recordsToProcess; $i++) {
$index = $lastProcessedIndex + $i;
// Maksimum çalışma süresini kontrol et
if ((time() - $startTime) >= $maxExecutionTime) {
Log::debug("⚠ Maximum execution time reached. Saving progress and stopping.");
// İlerlemeyi kaydet
setting_put($cacheKey, $index);
setting_put($progressCacheKey, json_encode([
'processed_count' => $processedCount,
'error_count' => $errorCount,
'success_count' => $successCount,
'total_records' => $progress['total_records']
]));
break 3; // Tüm döngülerden çık
}
// Memory kontrolü
if (!checkMemoryLimit($initialMemory, $maxMemoryLimit)) {
Log::debug("⚠ Memory limit reached. Saving progress and stopping.");
setting_put($cacheKey, $index);
setting_put($progressCacheKey, json_encode([
'processed_count' => $processedCount,
'error_count' => $errorCount,
'success_count' => $successCount,
'total_records' => $progress['total_records']
]));
break 3;
}
$rowData = $resultMaster[$index];
Log::debug("--- Processing Record " . ($index + 1) . " (Template: {$templateId}) ---");
// Convert object to array if needed
$rowDataArray = is_object($rowData) ? (array)$rowData : $rowData;
// Prepare POST data for the report generator
$_POST = [
'sqlCodeMaster' => $fields->editorMaster,
'sqlCodeDetail' => $fields->editorDetail ?? "",
'templateRowNo' => $fields->templateRowNo ?? 25,
'documentId' => $documentTemplate->id,
'fileNameTemplate' => $fields->fileNameTemplate ?? 'report_{line_number}',
'rowData' => $rowDataArray,
'isMultipleMode' => isset($fields->isMultipleMode) ? $fields->isMultipleMode : false,
'repeatedRows' => isset($fields->repeatedRows) ? json_encode($fields->repeatedRows) : json_encode([]),
'isSingleMode' => isset($fields->isSingleMode) ? $fields->isSingleMode : true,
'repeatRowCheckbox' => isset($fields->repeatRowCheckbox) ? $fields->repeatRowCheckbox : false,
'repeatedTableCount' => isset($fields->repeatedTableCount) ? $fields->repeatedTableCount : 1
];
$recordStartTime = microtime(true);
try {
// Render the report-builder-pdf-generator view directly
Log::debug("📄 Rendering report-builder-pdf-generator view...");
$response = view('admin-ajax.report-builder-pdf-generator')->render();
$recordEndTime = microtime(true);
$executionTime = round(($recordEndTime - $recordStartTime) * 1000, 2);
Log::debug("✅ Response generated successfully");
Log::debug("⏱️ Execution time: {$executionTime}ms");
// Increment counters after successful processing
$processedCount++;
$successCount++;
$totalProcessedInThisRun++;
} catch (Exception $e) {
$recordEndTime = microtime(true);
$executionTime = round(($recordEndTime - $recordStartTime) * 1000, 2);
Log::debug("❌ Error processing row: " . $e->getMessage());
Log::debug("⏱️ Execution time before error: {$executionTime}ms");
$errorCount++;
$totalProcessedInThisRun++;
}
// Progress'i güncelle
$lastProcessedIndex = $index + 1;
$templateProgress[$templateId]['lastProcessedIndex'] = $lastProcessedIndex;
$templateProgress[$templateId]['progress']['processed_count'] = $processedCount;
$templateProgress[$templateId]['progress']['error_count'] = $errorCount;
$templateProgress[$templateId]['progress']['success_count'] = $successCount;
// Setting'e kaydet
setting_put($cacheKey, $lastProcessedIndex);
setting_put($progressCacheKey, json_encode([
'processed_count' => $processedCount,
'error_count' => $errorCount,
'success_count' => $successCount,
'total_records' => $progress['total_records']
]));
// Gelişmiş bellek temizliği
unset($rowData, $rowDataArray, $response, $recordStartTime, $recordEndTime, $executionTime);
cleanupMemory();
// Her 5 işlemde bir database bağlantısını yenile
$databaseRefreshCounter++;
if ($databaseRefreshCounter >= 5) {
refreshDatabaseConnection();
$databaseRefreshCounter = 0;
}
// Add a small delay to prevent overwhelming the server
Log::debug("⏳ Waiting 2 seconds before next record...");
sleep(2);
}
/*
Log::debug("--- Template ID: {$templateId} Round Complete ---");
Log::debug("Current Statistics:");
Log::debug(" - Total records in master query: " . count($resultMaster));
Log::debug(" - Successfully processed: {$successCount}");
Log::debug(" - Failed to process: {$errorCount}");
Log::debug(" - Current index: {$lastProcessedIndex}");
*/
} else {
if(!isset($fields->editorDetail)) {
Log::debug("❌ Editor Detail SQL not found");
}
if(empty($resultMaster)) {
Log::debug("❌ Master query returned no results");
}
}
} else {
Log::debug("❌ Editor Master SQL not found");
}
// Template işlemi sonrası memory temizliği
unset($fields, $resultMaster);
cleanupMemory();
}
// Eğer hiç aktif template kalmadıysa döngüden çık
if ($activeTemplates == 0) {
Log::debug("🎉 All templates completed!");
break;
}
Log::debug("🔄 Completed one round for all templates. Total processed in this run: {$totalProcessedInThisRun}");
Log::debug("⏳ Waiting 5 seconds before next round...");
sleep(5);
}
$totalExecutionTime = time() - $startTime;
$finalMemory = memory_get_usage(true);
$peakMemory = memory_get_peak_usage(true);
Log::debug("=== CRON REPORT BUILDER QUEUE COMPLETED ===");
Log::debug("Total execution time: {$totalExecutionTime} seconds");
Log::debug("Final memory usage: " . round($finalMemory / 1024 / 1024, 2) . " MB");
Log::debug("Peak memory usage: " . round($peakMemory / 1024 / 1024, 2) . " MB");
Log::debug("Final timestamp: " . date('Y-m-d H:i:s'));
// Tüm işlemler bittikten sonra sadece başladığınız template'in progress'ini yenile
if ($activeTemplates == 0) {
Log::debug("🔄 All templates completed. Resetting progress for next cycle...");
// Sadece bu çalıştırmada işlem yapılan template'lerin progress'ini sıfırla
foreach ($templateProgress as $templateId => $progressInfo) {
$cacheKey = $progressInfo['cacheKey'];
$progressCacheKey = $progressInfo['progressCacheKey'];
// Eğer bu template'de işlem yapıldıysa (lastProcessedIndex > 0) progress'i sıfırla
if ($progressInfo['lastProcessedIndex'] > 0) {
Log::debug("🔄 Resetting progress for Template ID: {$templateId}");
setting_put($cacheKey, 0); // İndeksi sıfırla
setting_put($progressCacheKey, json_encode([
'processed_count' => 0,
'error_count' => 0,
'success_count' => 0,
'total_records' => 0
]));
} else {
Log::debug("⏸️ Skipping progress reset for Template ID: {$templateId} (no processing done)");
}
}
Log::debug("✅ Progress reset completed for processed templates only");
}
// Genel ilerleme bilgisini setting'e kaydet
$overallProgress = [
'last_run' => date('Y-m-d H:i:s'),
'execution_time' => $totalExecutionTime,
'final_memory_mb' => round($finalMemory / 1024 / 1024, 2),
'peak_memory_mb' => round($peakMemory / 1024 / 1024, 2),
'status' => ($totalExecutionTime >= $maxExecutionTime) ? 'timeout' : 'completed',
'total_processed_in_run' => $totalProcessedInThisRun
];
setting_put('cron_report_builder_overall_progress', json_encode($overallProgress));
// Final cleanup
cleanupMemory();
refreshDatabaseConnection();
?>
-271
View File
@@ -1,271 +0,0 @@
@if(!getisset("type"))
<?php
$result = Artisan::call('schedule:run');
dump("Schedule run: $result");
?>
@include("cron-register-creator")
<?php
// Check if current time is within night shift hours (20:00 to 07:00)
$currentHour = (int) date("H");
$isNightShift = ($currentHour >= 20 || $currentHour < 7);
if ($isNightShift) {
dump("Night shift");
} else {
dump("Day shift");
}
?>
@if($isNightShift)
@include("cron-report-builder-queue")
@endif
@endif
<?php
ini_set('memory_limit', '8G');
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
set_time_limit(-1);
ini_set('max_execution_time', -1);
$adminMail = env("ADMIN_MAIL");
// Regular cron jobs working time
$workingTime = [
// '12:00',
// '12:00',
'23:00',
'02:00',
//'10:30',
];
// Cache-blade cron jobs working time - separate schedule
$cacheWorkingTime = [
'06:00',
'09:00',
'12:00',
'15:00',
'18:00',
'21:00',
'00:00',
'03:00',
];
$cronJobPeriod = setting('cron_job_period');
$oneMinuteAgo = Carbon::now()->subMinutes($cronJobPeriod);
$take = setting('cron_job_batch_process_count');
$saat = date("H:i");
$dakika = (int) date("i");
$period = 30;
$kalan = $dakika % $period;
$commitSize = 250;
// Determine whether to process cache files or regular files based on current time
$isCacheTime = in_array($saat, $cacheWorkingTime);
$isRegularTime = in_array($saat, $workingTime);
if(!getisset("type"))
{
// Only allow the script to run at specified times
if (getisset("cache")) {
// If cache parameter is explicitly provided, use it to override time-based decision
$runCacheFiles = get("cache") == 1;
if ($runCacheFiles && !$isCacheTime) {
dump($saat);
dump($cacheWorkingTime);
dump("Cache Working Time Out");
exit();
} else if (!$runCacheFiles && !$isRegularTime) {
dump($saat);
dump($workingTime);
dump("Working Time Out");
exit();
}
} else {
// No cache parameter - automatically decide based on current time
if (!$isCacheTime && !$isRegularTime) {
dump($saat);
dump("Working Time Out - Not in any scheduled time");
dump("Regular times: " . implode(", ", $workingTime));
dump("Cache times: " . implode(", ", $cacheWorkingTime));
exit();
}
// If both cache and regular time overlap, cache takes precedence
}
}
Cache::forget("cronjob");
if(!getesit("type","")) {
Cache::forget("cronjob");
}
if($saat == "11:00")
{
Cache::forget("cronjob");
dump("forget cronjob");
}
if(!Cache::has("cronjob")) {
// if($kalan == 0) {
$start = new Carbon(simdi());
Cache::put("cronjob", simdi());
Log::debug("🟢 cron start: " . simdi());
// Get all blade files from cron directory
$allFiles = glob(base_path() . '/resources/views/cron/*.blade.php');
// Separate cache-blade files from other files
$cacheFiles = [];
$regularFiles = [];
foreach($allFiles as $file) {
$basename = basename($file);
if(strpos($basename, 'cache-blade') === 0) {
$cacheFiles[] = $file;
} else {
$regularFiles[] = $file;
}
}
// Determine which files to process based on request or time
$filesToProcess = [];
if(getisset("type")) {
// If specific type is requested, include only that file
$filesToProcess = $allFiles;
} else if(getisset("cache")) {
// If cache parameter is explicitly provided
$runCacheFiles = get("cache") == 1;
if($runCacheFiles) {
$filesToProcess = $cacheFiles;
Log::debug("Processing only cache-blade files (explicit): " . count($cacheFiles));
} else {
$filesToProcess = $regularFiles;
Log::debug("Processing regular cron files (explicit): " . count($regularFiles));
}
} else {
// Auto determine based on current time
// If both time ranges overlap, cache takes precedence
if($isCacheTime) {
$filesToProcess = $cacheFiles;
Log::debug("Processing cache-blade files (auto time-based): " . count($cacheFiles));
} else if($isRegularTime) {
$filesToProcess = $regularFiles;
Log::debug("Processing regular cron files (auto time-based): " . count($regularFiles));
} else {
// This shouldn't happen due to earlier check, but just in case
$filesToProcess = [];
Log::debug("No files to process - not in any scheduled time");
}
}
$count = 0;
$total = count($filesToProcess);
?>
@if(!getesit("type",""))
@includeIf('cron.' . get("type"))
@else
@foreach ($filesToProcess as $file)
<?php
//ob_start();
$description = basename($file);
$description = str_replace(".blade.php", "", $description);
Log::info($file);
Cache::put("cronjob_progress", [
'total' => $total,
'count' => $count,
'progress' => round($count * 100 / $total),
'description' => $description,
'start' => simdi()
]);
$count++;
try {
?>
@include('cron.' . basename(str_replace('.blade.php', '', $file)))
<?php
} catch (\Throwable $th) {
Log::error("cron");
Log::error($th->getMessage());
Cache::forget("cronjob");
dump($th);
mailSend($adminMail, env("APP_NAME")." Cron Job Error", $th->getMessage());
}
?>
<?php
// ob_end_clean();
//gc_collect_cycles();
?>
@endforeach
@endif
<?php
$end = new Carbon(simdi());
if(!getisset("type")) {
Cache::put("cronjob_progress", [
'total' => $total,
'count' => $total,
'progress' => 100,
'start' => simdi(),
'description' => "finish " . simdi() . " " . $start->diff($end)->format('%H:%I:%S')
]);
}
Log::debug("🔴 cron finish: " . simdi());
Log::debug("⏰ süre: " . $start->diff($end)->format('%H:%I:%S'));
Cache::forget("cronjob");
//.. mailSend($adminMail, env("APP_NAME")." Cron Job Finished", "Cron Job Finished");
/*
} else {
// dump($period - $kalan);
dump("Cron ". $period - $kalan ." dakika sonra çalışacak");
}
*/
?>
<?php
} else {
$runControlAttempt = Cache::get("cronJobRunControlAttempt");
if(is_null($runControlAttempt))
{
$runControlAttempt = 0;
}
$runControlAttempt++;
Cache::put("cronJobRunControlAttempt", $runControlAttempt);
if($runControlAttempt == 100)
{
Cache::forget("cronjob");
Cache::forget("cronJobRunControlAttempt");
Log::debug("Cron job 100 dakikadır çalışıyor. Tekrar başlatılacak...");
}
dump("cronJobRunControlAttempt $runControlAttempt");
dump("Çalışan bir cron var onun bitmesini bekliyorum");
Log::debug("Çalışan bir cron var onun bitmesini bekliyorum");
}
?>
-99
View File
@@ -1,99 +0,0 @@
<?php
// Admin authentication check
$providedPassword = request('password');
$isAdmin = false;
// Check if user is admin and password is correct
if (auth()->check() && auth()->user()->level === 'Admin') {
// Check if provided password matches the admin user's password in database
if (Hash::check($providedPassword, auth()->user()->password)) {
$isAdmin = true;
} else {
echo "❌ Admin password is incorrect!";
exit();
}
} else {
echo "❌ Admin privileges required to access this page!";
exit();
}
// Only proceed if admin authentication is successful
if (!$isAdmin) {
echo "❌ Authorization error!";
exit();
}
// Set execution settings
ini_set('memory_limit', '8G');
set_time_limit(-1);
ini_set('max_execution_time', -1);
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
$adminMail = env("ADMIN_MAIL");
$start = new Carbon(simdi());
Log::debug("🟢 Important Job start: " . simdi());
// Get all blade files from important-job directory
$allFiles = glob(base_path() . '/resources/views/important-job/*.blade.php');
$count = 0;
$total = count($allFiles);
if ($total == 0) {
echo "❌ No files found in important-job folder!";
exit();
}
echo "📁 Total $total files will be processed...<br><br>";
?>
@php
$count = 0;
@endphp
@foreach($allFiles as $file)
@php
$description = basename($file, '.blade.php');
$count++;
echo "🔄 Processing ($count/$total): $description<br>";
Log::info("Processing: $file");
try {
@endphp
@includeIf('important-job.' . $description)
@php
echo "✅ Success: $description<br>";
} catch (\Throwable $th) {
Log::error("Important Job Error in $description");
Log::error($th->getMessage());
echo "❌ Error ($description): " . $th->getMessage() . "<br>";
if ($adminMail) {
mailSend($adminMail, env("APP_NAME")." Important Job Error",
"File: $description\nError: " . $th->getMessage());
}
}
echo "<br>";
@endphp
@endforeach
<?php
$end = new Carbon(simdi());
$duration = $start->diff($end)->format('%H:%I:%S');
echo "🎉 All operations completed!<br>";
echo "⏱️ Total duration: $duration<br>";
Log::debug("🔴 Important Job finish: " . simdi());
Log::debug("⏰ Duration: $duration");
// Send completion email to admin
if ($adminMail) {
mailSend($adminMail, env("APP_NAME")." Important Job Completed",
"Total $total files processed.\nDuration: $duration");
}
?>
@@ -1,11 +0,0 @@
@extends('admin.master')
@section("title", get("title"))
<?php $type = get("type");
$id = "summary";
?>
@section('content')
@if(Hash::check($type, get("hash")))
@includeIf("admin.type.$type")
@endif
@endsection
-1
View File
@@ -1 +0,0 @@
@includeCache("mail-link-content")