init project

This commit is contained in:
2026-05-25 11:08:52 +07:00
parent a388c619b5
commit 895fdd9b83
1437 changed files with 384844 additions and 27 deletions

View File

@@ -0,0 +1,52 @@
<?php
namespace App\Console\Commands;
use App\Models\Laboratory;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class DisableLabAccess extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'laboratory:disable';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
try{
$labs = Laboratory::query()->where('record_status_id', 1)
->whereRaw("DATEDIFF(end_date, CURDATE())<=-7")
->update(['record_status_id' => 0]);
Log::channel('jobs')->info($labs);
} catch (\Exception $e){
Log::channel('jobs')->error($e->getMessage());
}
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace App\Console\Commands;
use App\Models\Laboratory;
use App\Models\Publication;
use App\Models\PublicationReceiver;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class NotifyExpireLab extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'notify:send';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
try{
$labs = Laboratory::query()->where('record_status_id', 1)
->whereNotNull('end_date')
->whereRaw("DATEDIFF(end_date, CURDATE())=7")->get();
Log::channel('jobs')->info($labs);
foreach ($labs as $lab){
$date= date_create(date('Y-m-d', strtotime($lab->end_date)));
date_add($date,date_interval_create_from_date_string("7 days"));
$_disable_date = date_format($date,"d-M-Y");
$publication = Publication::query()->create([
'title_en' => "License Expiry Alert",
'title_kh' => "សេចក្តីជូនដំណឹងអំពីការផុតសុំពលភាពនៃការប្រើប្រាស់ប្រព័ន្ធ Labonak",
'start_date' => date('Y-m-d'),
'end_date' => date('Y-m-d', strtotime($lab->end_date)),
'description' => "គណនីប្រើប្រាស់ប្រព័ន្ធរបស់លោកអ្នកនឹងផ្អាកប្រើប្រាស់ជាបណ្ណោះអាសន្ននៅថ្ងៃ " . $_disable_date . " សូមទំនាក់ទំនងទៅកាន់ System Administrator ដើម្បីបន្តសុពលភាព។ សូមអរគុណ!"
]);
PublicationReceiver::query()->create([
'publication_id' => $publication->id,
'lab_id' => $lab->id,
'created_by' => 1
]);
}
} catch (\Exception $e){
Log::channel('jobs')->error($e->getMessage());
}
}
}

41
app/Console/Kernel.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}