Commit d9e7ef9c authored by Sarun Mungthanya's avatar Sarun Mungthanya
Browse files

add laravel telescope and fix paginate

parent 06d55160
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
class ExportProgressUpdated implements ShouldBroadcast
{
use InteractsWithSockets, SerializesModels;
public $progress;
public function __construct($progress)
{
$this->progress = $progress;
}
public function broadcastOn()
{
return new Channel('export-progress');
}
}
\ No newline at end of file
......@@ -3,15 +3,42 @@
namespace App\Exports;
use App\Models\ConfServerLicense;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
class ServerLicenseExport implements FromCollection
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
class ServerLicenseExport implements FromCollection, WithHeadings, WithColumnFormatting
{ public function collection()
{
$select = "
SELECT c.`SNKEY` as 'SNKEY', c.`COMPANY`, c.`STATUS`, c.`LICENSEDATE`, c.`BACKUP_DATE`,
c.`CUR_VERSION`, c.`INSTALL_DATE`, c.`INSTALL_VERSION`, c.`DATABASETYPE`, c.`OWNERTYPE`,
c.`NBTEAM`, c.`CUSTOMERSIZE`, c.`CUSTOMERTYPE`, c.`CUSTOMERBRANCH`, c.`CONTACTCUSTOMERNAME`,
c.`CONTACT`, c.`CUSTOMERURL`, c.`MESSAGETYPE`, c.`PHP_VERSION_ID`, j.`javaversion` as 'JAVA_VERSION'
FROM conf_server_license c
LEFT JOIN conf_server_license_javaversion j ON c.SNKEY = j.SNKEY
";
return collect(DB::select($select));
}
public function headings(): array
{
return [
'SNKEY', 'COMPANY', 'STATUS', 'LICENSEDATE', 'BACKUP_DATE', 'CUR_VERSION', 'INSTALL_DATE', 'INSTALL_VERSION',
'DATABASETYPE', 'OWNERTYPE', 'NBTEAM', 'CUSTOMERSIZE', 'CUSTOMERTYPE', 'CUSTOMERBRANCH', 'CONTACTCUSTOMERNAME',
'CONTACT', 'CUSTOMERURL', 'MESSAGETYPE', 'PHP_VERSION_ID', 'JAVA VERSION'
];
}
public function columnFormats(): array
{
return ConfServerLicense::all();
return [
'A' => NumberFormat::FORMAT_TEXT,
];
}
}
......@@ -15,10 +15,6 @@ class MainContainer extends Component
public function loadContent($menu)
{
$this->loading = true;
// Simulate loading delay
// sleep(1);
$this->currentContent = $menu;
$this->loading = false;
}
......
......@@ -8,7 +8,11 @@ class Navbar extends Component
{
public $currentMenu = 'DeleteMultiPatch';
public $navLoaded = false;
public $userName ;
public function mount() {
$this->userName = auth()->user()->username;
}
public function loadNav()
{
$this->navLoaded = true;
......@@ -16,7 +20,7 @@ class Navbar extends Component
public function loadContent($menu)
{
$this->currentMenu = $menu;
$this->emit('menuChanged', $menu);
$this->emit('menuChanged', $menu);
}
public function render()
......
......@@ -2,8 +2,16 @@
namespace App\Http\Livewire\Pages\Report;
use App\Exports\ServerLicenseExport;
use App\Jobs\ExportChunkJob;
use App\Jobs\ExportReportJob;
use App\Models\ConfServerLicense;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
use Livewire\Component;
use Illuminate\Bus\Batch;
use Illuminate\Support\Facades\Bus;
use Throwable;
class ReportIndex extends Component
{
......@@ -18,7 +26,13 @@ class ReportIndex extends Component
public $searchSelected;
public $keyword;
public $results;
protected $results;
public $progress = 0;
public $exporting = false;
public $fileName;
public $jobId;
public $batchId;
public $status = '';
public function filterReport()
{
......@@ -31,11 +45,64 @@ class ReportIndex extends Component
$this->results = $query->orderBy('ID', 'DESC')->get();
}
// public function exportReport()
// {
// // ฟังก์ชันสำหรับการ export ข้อมูลเป็นไฟล์
// return Excel::download(new ConfServerLicenseExport($this->results), 'report.xlsx');
// }
public function exportReport()
{
$this->exporting = true;
$fileName = 'report_' . time() . '.xlsx';
$chunks = $this->getDataInChunks();
// สร้าง batch jobs โดยไม่ต้องใช้ withBatchId
$batch = Bus::batch(
collect($chunks)->map(fn($rows) => new ExportChunkJob($rows, $fileName))->toArray()
)->then(function (Batch $batch) {
// เมื่อ batch เสร็จสมบูรณ์
$this->progress = 100;
$this->status = 'Completed';
$this->exporting = false;
})->catch(function (Batch $batch, Throwable $e) {
// เมื่อ batch ล้มเหลว
$this->status = 'Failed';
$this->exporting = false;
})->finally(function (Batch $batch) {
$this->emit('checkProgress'); // เรียก Livewire เช็ค progress
})->dispatch();
$this->batchId = $batch->id; // เก็บ batchId ไว้เพื่อตรวจสอบ progress
$this->emit('startPolling'); // เริ่ม polling เพื่อติดตาม progress
}
public function checkProgress()
{
// เช็ค progress โดยใช้ batchId
if ($this->batchId) {
$batch = Bus::findBatch($this->batchId);
if ($batch) {
$this->progress = $batch->progress(); // อัปเดต progress
if ($batch->finished()) {
$this->status = 'Completed';
$this->exporting = false;
}
}
}
}
public function getDataInChunks()
{
$chunks = [];
// ใช้ chunk() โดยมี callback function เป็นพารามิเตอร์ที่สอง
ConfServerLicense::select('ID', 'SNKEY', 'COMPANY', 'STATUS', 'CUR_VERSION', 'DATABASETYPE', 'LICENSEDATE')
->orderBy('ID', 'DESC')
->chunk(100, function($rows) use (&$chunks) {
$chunks[] = $rows;
});
return $chunks;
}
public function render()
{
$this->filterReport();
......
......@@ -19,13 +19,14 @@ class RoleIndex extends Component
public $editRoleId;
public $deleteRoleId;
public $keyword = '';
public $route = '';
public $route = '';
public $selectedOption = 'name';
public $searchBy;
public $menu;
public $action = 'list';
public $message;
public $selectedRoles ,$permission_lists= [];
public $selectedRoles ;
public $permissionLists= [];
public $showDeleteListModal = false;
public $showNoPermissionModal = false;
public $showMessage = false;
......@@ -41,7 +42,6 @@ class RoleIndex extends Component
public function render()
{
// \Log::info('searchSelected:', ['searchSelected' => $this->searchSelected]);
$results = $this->searchSelected && $this->keyword
? Role::where($this->searchSelected, 'LIKE', '%' . $this->keyword . '%')->paginate($this->perPage)
: Role::paginate($this->perPage);
......
......@@ -12,10 +12,14 @@ use Illuminate\Support\Facades\Cache;
class SendPatchIndex extends Component
{
use WithPagination;
// protected $paginationTheme = 'bootstrap';
public $searchBy, $editPid, $message, $keyword, $perPage = 10, $searchSelected = 'PID',
// $action = 'list';
$action = 'list'; // test
public $searchBy;
public $editPid;
public $message;
public $keyword;
public $perPage = 10;
public $searchSelected = 'PID';
public $action = 'list';
protected $listeners = ['showGroupList', 'deleteItem', 'deleteSelected'];
......@@ -34,28 +38,18 @@ class SendPatchIndex extends Component
public function render()
{
$results = [];
$results = [];
if ($this->action == 'list') {
DB::table('conf_server_pendding')->index(['ServerID', 'PatchID']);
$numServerSubquery = DB::table('conf_server_pendding as p2')
->select(DB::raw('count(p2.ServerID) as NUMSERVER'), 'p2.PatchID')
->groupBy('p2.PatchID');
// Query หลัก
$query = ConfSmartUpdate::from('conf_smartupdate as p1')
->select('p1.PID', 'p1.PATCHNAME', 'p1.PDESC', 'p1.PDATE', 'p1.PLEVEL', 'p1.Remark', 'p3.NUMSERVER')
->leftJoinSub($numServerSubquery, 'p3', function ($join) {
$join->on('p1.PID', '=', 'p3.PatchID');
});
$query = ConfSmartUpdate::select('PID', 'PATCHNAME', 'PDESC', 'PDATE', 'PLEVEL', 'Remark')
->withCount(['confServerPendding as NUMSERVER']);
if ($this->searchSelected && $this->keyword) {
$query->where($this->searchSelected, 'LIKE', $this->keyword . '%');
}
$query->orderBy('p1.PID', 'DESC');
$query->orderBy('PID', 'DESC');
$results = $query->paginate($this->perPage);
}
// $results = [];
// dd($results);
return view('livewire.pages.send-patch.send-patch-index', compact('results'));
}
......
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ExportChunkJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $rows;
protected $fileName;
public function __construct($rows, $fileName)
{
$this->rows = $rows;
$this->fileName = $fileName;
}
public function handle()
{
// ประมวลผลข้อมูลใน $rows
// เช่น ใช้ Excel::store() เพื่อสร้างไฟล์สำหรับ chunk นั้น
\Maatwebsite\Excel\Facades\Excel::store(new \App\Exports\ServerLicenseExport($this->rows), $this->fileName, 'local');
}
}
\ No newline at end of file
<?php
namespace App\Jobs;
use Maatwebsite\Excel\Facades\Excel;
use App\Exports\ServerLicenseExport;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class ExportReportJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $fileName;
public $jobId;
public function __construct($fileName, $jobId)
{
$this->fileName = $fileName;
$this->jobId = $jobId;
}
public function handle()
{
$totalRows = DB::table('conf_server_license')->count(); // จำนวนข้อมูลทั้งหมด
$processedRows = 0;
// ใช้ chunk เพื่อแบ่งการประมวลผล
DB::table('conf_server_license')->chunk(100, function ($rows) use (&$processedRows, $totalRows) {
// ประมวลผลข้อมูลใน chunk
Excel::store(new ServerLicenseExport($rows), $this->fileName, 'local');
// เพิ่มจำนวนข้อมูลที่ถูกประมวลผล
$processedRows += count($rows);
// คำนวณเปอร์เซ็นต์ความคืบหน้า
$progress = ($processedRows / $totalRows) * 100;
// อัปเดต progress ลงใน cache แทนฐานข้อมูล
Cache::put("export_progress_{$this->jobId}", $progress);
});
// ลบค่า progress เมื่อประมวลผลเสร็จสิ้น
Cache::forget("export_progress_{$this->jobId}");
}
}
\ No newline at end of file
......@@ -12,14 +12,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Collection;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable , SoftDeletes;
use HasApiTokens, HasFactory, Notifiable ;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $dates = ['deleted_at'];
protected $fillable = [
'username',
'first_name',
......
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeApplicationServiceProvider;
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
// Telescope::night();
$this->hideSensitiveRequestDetails();
$isLocal = $this->app->environment('local');
Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
return $isLocal ||
$entry->isReportableException() ||
$entry->isFailedRequest() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}
/**
* Prevent sensitive request details from being logged by Telescope.
*/
protected function hideSensitiveRequestDetails(): void
{
if ($this->app->environment('local')) {
return;
}
Telescope::hideRequestParameters(['_token']);
Telescope::hideRequestHeaders([
'cookie',
'x-csrf-token',
'x-xsrf-token',
]);
}
/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*/
protected function gate(): void
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
//
]);
});
}
}
......@@ -24,6 +24,13 @@
0 => 'Laravel\\Sanctum\\SanctumServiceProvider',
),
),
'laravel/telescope' =>
array (
'providers' =>
array (
0 => 'Laravel\\Telescope\\TelescopeServiceProvider',
),
),
'laravel/tinker' =>
array (
'providers' =>
......
......@@ -26,18 +26,20 @@
22 => 'Barryvdh\\Debugbar\\ServiceProvider',
23 => 'Laravel\\Sail\\SailServiceProvider',
24 => 'Laravel\\Sanctum\\SanctumServiceProvider',
25 => 'Laravel\\Tinker\\TinkerServiceProvider',
26 => 'Livewire\\LivewireServiceProvider',
27 => 'Maatwebsite\\Excel\\ExcelServiceProvider',
28 => 'Carbon\\Laravel\\ServiceProvider',
29 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
30 => 'Termwind\\Laravel\\TermwindServiceProvider',
31 => 'Spatie\\LaravelIgnition\\IgnitionServiceProvider',
32 => 'App\\Providers\\AppServiceProvider',
33 => 'App\\Providers\\AuthServiceProvider',
34 => 'App\\Providers\\EventServiceProvider',
35 => 'App\\Providers\\RouteServiceProvider',
36 => 'App\\Providers\\ViewServiceProvider',
25 => 'Laravel\\Telescope\\TelescopeServiceProvider',
26 => 'Laravel\\Tinker\\TinkerServiceProvider',
27 => 'Livewire\\LivewireServiceProvider',
28 => 'Maatwebsite\\Excel\\ExcelServiceProvider',
29 => 'Carbon\\Laravel\\ServiceProvider',
30 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
31 => 'Termwind\\Laravel\\TermwindServiceProvider',
32 => 'Spatie\\LaravelIgnition\\IgnitionServiceProvider',
33 => 'App\\Providers\\AppServiceProvider',
34 => 'App\\Providers\\AuthServiceProvider',
35 => 'App\\Providers\\EventServiceProvider',
36 => 'App\\Providers\\RouteServiceProvider',
37 => 'App\\Providers\\TelescopeServiceProvider',
38 => 'App\\Providers\\ViewServiceProvider',
),
'eager' =>
array (
......@@ -53,17 +55,19 @@
9 => 'Illuminate\\View\\ViewServiceProvider',
10 => 'Barryvdh\\Debugbar\\ServiceProvider',
11 => 'Laravel\\Sanctum\\SanctumServiceProvider',
12 => 'Livewire\\LivewireServiceProvider',
13 => 'Maatwebsite\\Excel\\ExcelServiceProvider',
14 => 'Carbon\\Laravel\\ServiceProvider',
15 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
16 => 'Termwind\\Laravel\\TermwindServiceProvider',
17 => 'Spatie\\LaravelIgnition\\IgnitionServiceProvider',
18 => 'App\\Providers\\AppServiceProvider',
19 => 'App\\Providers\\AuthServiceProvider',
20 => 'App\\Providers\\EventServiceProvider',
21 => 'App\\Providers\\RouteServiceProvider',
22 => 'App\\Providers\\ViewServiceProvider',
12 => 'Laravel\\Telescope\\TelescopeServiceProvider',
13 => 'Livewire\\LivewireServiceProvider',
14 => 'Maatwebsite\\Excel\\ExcelServiceProvider',
15 => 'Carbon\\Laravel\\ServiceProvider',
16 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
17 => 'Termwind\\Laravel\\TermwindServiceProvider',
18 => 'Spatie\\LaravelIgnition\\IgnitionServiceProvider',
19 => 'App\\Providers\\AppServiceProvider',
20 => 'App\\Providers\\AuthServiceProvider',
21 => 'App\\Providers\\EventServiceProvider',
22 => 'App\\Providers\\RouteServiceProvider',
23 => 'App\\Providers\\TelescopeServiceProvider',
24 => 'App\\Providers\\ViewServiceProvider',
),
'deferred' =>
array (
......
......@@ -194,6 +194,7 @@ return [
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
App\Providers\ViewServiceProvider::class,
],
......
<?php
use Laravel\Telescope\Http\Middleware\Authorize;
use Laravel\Telescope\Watchers;
return [
/*
|--------------------------------------------------------------------------
| Telescope Master Switch
|--------------------------------------------------------------------------
|
| This option may be used to disable all Telescope watchers regardless
| of their individual configuration, which simply provides a single
| and convenient way to enable or disable Telescope data storage.
|
*/
'enabled' => env('TELESCOPE_ENABLED', true),
/*
|--------------------------------------------------------------------------
| Telescope Domain
|--------------------------------------------------------------------------
|
| This is the subdomain where Telescope will be accessible from. If the
| setting is null, Telescope will reside under the same domain as the
| application. Otherwise, this value will be used as the subdomain.
|
*/
'domain' => env('TELESCOPE_DOMAIN'),
/*
|--------------------------------------------------------------------------
| Telescope Path
|--------------------------------------------------------------------------
|
| This is the URI path where Telescope will be accessible from. Feel free
| to change this path to anything you like. Note that the URI will not
| affect the paths of its internal API that aren't exposed to users.
|
*/
'path' => env('TELESCOPE_PATH', 'telescope'),
/*
|--------------------------------------------------------------------------
| Telescope Storage Driver
|--------------------------------------------------------------------------
|
| This configuration options determines the storage driver that will
| be used to store Telescope's data. In addition, you may set any
| custom options as needed by the particular driver you choose.
|
*/
'driver' => env('TELESCOPE_DRIVER', 'database'),
'storage' => [
'database' => [
'connection' => env('DB_CONNECTION', 'mysql'),
'chunk' => 1000,
],
],
/*
|--------------------------------------------------------------------------
| Telescope Queue
|--------------------------------------------------------------------------
|
| This configuration options determines the queue connection and queue
| which will be used to process ProcessPendingUpdate jobs. This can
| be changed if you would prefer to use a non-default connection.
|
*/
'queue' => [
'connection' => env('TELESCOPE_QUEUE_CONNECTION', null),
'queue' => env('TELESCOPE_QUEUE', null),
],
/*
|--------------------------------------------------------------------------
| Telescope Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Telescope route, giving you
| the chance to add your own middleware to this list or change any of
| the existing middleware. Or, you can simply stick with this list.
|
*/
'middleware' => [
'web',
Authorize::class,
],
/*
|--------------------------------------------------------------------------
| Allowed / Ignored Paths & Commands
|--------------------------------------------------------------------------
|
| The following array lists the URI paths and Artisan commands that will
| not be watched by Telescope. In addition to this list, some Laravel
| commands, like migrations and queue commands, are always ignored.
|
*/
'only_paths' => [
// 'api/*'
],
'ignore_paths' => [
'livewire*',
'nova-api*',
'pulse*',
],
'ignore_commands' => [
//
],
/*
|--------------------------------------------------------------------------
| Telescope Watchers
|--------------------------------------------------------------------------
|
| The following array lists the "watchers" that will be registered with
| Telescope. The watchers gather the application's profile data when
| a request or task is executed. Feel free to customize this list.
|
*/
'watchers' => [
Watchers\BatchWatcher::class => env('TELESCOPE_BATCH_WATCHER', true),
Watchers\CacheWatcher::class => [
'enabled' => env('TELESCOPE_CACHE_WATCHER', true),
'hidden' => [],
],
Watchers\ClientRequestWatcher::class => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true),
Watchers\CommandWatcher::class => [
'enabled' => env('TELESCOPE_COMMAND_WATCHER', true),
'ignore' => [],
],
Watchers\DumpWatcher::class => [
'enabled' => env('TELESCOPE_DUMP_WATCHER', true),
'always' => env('TELESCOPE_DUMP_WATCHER_ALWAYS', false),
],
Watchers\EventWatcher::class => [
'enabled' => env('TELESCOPE_EVENT_WATCHER', true),
'ignore' => [],
],
Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true),
Watchers\GateWatcher::class => [
'enabled' => env('TELESCOPE_GATE_WATCHER', true),
'ignore_abilities' => [],
'ignore_packages' => true,
'ignore_paths' => [],
],
Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
Watchers\LogWatcher::class => [
'enabled' => env('TELESCOPE_LOG_WATCHER', true),
'level' => 'error',
],
Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true),
Watchers\ModelWatcher::class => [
'enabled' => env('TELESCOPE_MODEL_WATCHER', true),
'events' => ['eloquent.*'],
'hydrations' => true,
],
Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true),
Watchers\QueryWatcher::class => [
'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
'ignore_packages' => true,
'ignore_paths' => [],
'slow' => 100,
],
Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true),
Watchers\RequestWatcher::class => [
'enabled' => env('TELESCOPE_REQUEST_WATCHER', true),
'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64),
'ignore_http_methods' => [],
'ignore_status_codes' => [],
],
Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true),
Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true),
],
];
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return config('telescope.storage.database.connection');
}
/**
* Run the migrations.
*/
public function up(): void
{
$schema = Schema::connection($this->getConnection());
$schema->create('telescope_entries', function (Blueprint $table) {
$table->bigIncrements('sequence');
$table->uuid('uuid');
$table->uuid('batch_id');
$table->string('family_hash')->nullable();
$table->boolean('should_display_on_index')->default(true);
$table->string('type', 20);
$table->longText('content');
$table->dateTime('created_at')->nullable();
$table->unique('uuid');
$table->index('batch_id');
$table->index('family_hash');
$table->index('created_at');
$table->index(['type', 'should_display_on_index']);
});
$schema->create('telescope_entries_tags', function (Blueprint $table) {
$table->uuid('entry_uuid');
$table->string('tag');
$table->primary(['entry_uuid', 'tag']);
$table->index('tag');
$table->foreign('entry_uuid')
->references('uuid')
->on('telescope_entries')
->onDelete('cascade');
});
$schema->create('telescope_monitoring', function (Blueprint $table) {
$table->string('tag')->primary();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$schema = Schema::connection($this->getConnection());
$schema->dropIfExists('telescope_entries_tags');
$schema->dropIfExists('telescope_entries');
$schema->dropIfExists('telescope_monitoring');
}
};
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
};
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('job_batches', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->text('failed_job_ids');
$table->mediumText('options')->nullable();
$table->timestamp('cancelled_at')->nullable();
$table->timestamp('finished_at')->nullable(); // เพิ่มคอลัมน์นี้
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('job_batches');
}
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment