Commit 82dcab0a by Phạm Văn Đoan

tạo Crontjob.php test

parent 306fdb5b
......@@ -6,11 +6,18 @@ APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_DATABASE=vmusicchart
DB_USERNAME=vmusic
DB_PASSWORD=Vmusic@2019###
DB_LOCAL_HOST=127.0.0.1
DB_LOCAL_PORT=3306
DB_LOCAL_DATABASE=vmusicchart
DB_LOCAL_USERNAME=root
DB_LOCAL_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
......
......@@ -8,3 +8,4 @@
Homestead.json
Homestead.yaml
.env
/composer.lock
<?php
namespace App\Console\Commands;
use App\Models\Crontjob;
use Carbon\Carbon;
use Illuminate\Console\Command;
class CrontjobCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'crontjob:test';
/**
* 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 mixed
*/
public function handle()
{
Crontjob::create(['message' => 'Crontjob is called at ' . Carbon::now()]);
}
}
......@@ -2,6 +2,7 @@
namespace App\Console;
use App\Console\Commands\CrontjobCommand;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
......@@ -13,7 +14,7 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
//
CrontjobCommand::class,
];
/**
......@@ -26,6 +27,10 @@ class Kernel extends ConsoleKernel
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('crontjob:test')->everyMinute();
$schedule->command('queue:work --once --timeout=120')->everyMinute()->withoutOverlapping();
}
/**
......
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Crontjob extends Model
{
protected $table = 'crontjobs';
public $timestamps = true;
protected $fillable = ['message'];
}
......@@ -41,16 +41,16 @@ return [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'host' => (env('APP_ENV') == 'production') ? env('DB_HOST') : env('DB_LOCAL_HOST'),
'port' => (env('APP_ENV') == 'production') ? env('DB_PORT') : env('DB_LOCAL_PORT'),
'database' => (env('APP_ENV') == 'production') ? env('DB_DATABASE') : env('DB_LOCAL_DATABASE'),
'username' => (env('APP_ENV') == 'production') ? env('DB_USERNAME') : env('DB_LOCAL_USERNAME'),
'password' => (env('APP_ENV') == 'production') ? env('DB_PASSWORD') : env('DB_LOCAL_PASSWORD'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'strict' => false,
'engine' => null,
],
......
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