Commit bbcb095e by doan281

cập nhật code

parent ed4c258c
APP_NAME=Laravel
APP_ENV=production
APP_ENV=localhost
#APP_ENV=production/localhost
APP_KEY=base64:OnxDnOd5hyBzqzaoj1c+yl17+9lQiallMbwKuitg4XU=
APP_DEBUG=true
......@@ -41,3 +41,6 @@ MAIL_FROM_NAME=VMusicChart.Vn
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
# YOUTUBE_API_KEY=AIzaSyAEPc-G8kluV2MZinW6CzP24T9Jk_In2aw
YOUTUBE_API_KEY=AIzaSyAoiNPZC26cXgNAz-s7Shqav5KuIL0BZ_8
<?php
namespace App\Console\Commands\Gameshow;
use App\Models\Gameshow\Answer;
use App\Models\Gameshow\Question;
use App\Models\Gameshow\Topic;
use Illuminate\Console\Command;
class QuestionCommand extends Command
{
protected $question;
protected $topic;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'gameshow:question';
/**
* 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(Question $question, Topic $topic)
{
$this->question = $question;
$this->topic = $topic;
$query = Question::select()
->with([
'topics' => function($sql) {
//$sql->select(['topics.id','topics.name'])->take(2);
$sql->select(['topics.id','topics.name']);
}
])
->withCount('topics')
->get()
->toArray();
print_r($query);
$result = collect($query)->map(function ($item){
})->all();
$q = Question::select('*')
->with([
'answers' => function($sql){
$sql->select(['answers.id', 'answers.name']);
}
])
->get()
->toArray();
print_r($q);
/*$as = Answer::select('*')->with([
'question' => function($sql){
$sql->select(['id', 'name']);
}
])->get()->toArray();
print_r($as);*/
}
}
......@@ -41,14 +41,22 @@ class YoutubeCrawlerListenCommand extends Command
*/
public function handle()
{
echo 'OK';
$url = 'https://www.youtube.com/watch?v=8mC7oNkz9t4';
//$url = 'https://www.youtube.com/watch?v=8mC7oNkz9t4';
//$video = Youtube::getVideoInfo('8mC7oNkz9t4');
$video = Youtube::getVideoInfo('UqKVL56IJB8');
//print_r($video);
$data = [
'id' => $video->id,
'published_at' => date('Y-m-d H:I:s', strtotime($video->snippet->publishedAt)),
'title' => $video->snippet->title,
'thumbnails' => $video->snippet->thumbnails->standard->url,
'duration' => $video->contentDetails->duration,
'view_count' => $video->statistics->viewCount,
];
echo Hash::make('123456a@A');
print_r($data);
//echo Hash::make('123456a@A');
......
......@@ -14,7 +14,7 @@ use App\Console\Commands\Nct\NctCrawlerTrackCommand;
use App\Console\Commands\NhacVn\NhacVnCrawlerTrackCommand;
use App\Console\Commands\SendWarningCommand;
use App\Console\Commands\Update\UpdateTrackArtistCommand;
use App\Console\Commands\Ynv\YnvCommand;
use App\Console\Commands\Youtube\YoutubeCrawlerListenCommand;
use App\Console\Commands\Zing\ZingCrawlerNewRealeaseCommand;
use App\Console\Commands\Zing\ZingCrawlerTrackCommand;
use App\Console\Commands\CrawlerTrackImageCommand;
......@@ -30,7 +30,7 @@ class Kernel extends ConsoleKernel
*/
protected $commands = [
CrontjobCommand::class,
YnvCommand::class,
YoutubeCrawlerListenCommand::class,
ZingCrawlerTrackCommand::class,
ZingCrawlerNewRealeaseCommand::class,
......@@ -109,8 +109,7 @@ class Kernel extends ConsoleKernel
$schedule->command('send:email warning_weekly_report')->dailyAt('8:05');
$schedule->command('send:email warning_monthly_report')->dailyAt('8:10');
// Gửi mail nhắc nhở check CMS hàng ngày trước 9h
// Tạm dừng gửi vì đã triển khai lên hệ thống khác
//$schedule->command('send:email daily_checking')->dailyAt('9:01');
$schedule->command('send:email daily_checking')->dailyAt('9:01');
$schedule->command('queue:work --once --timeout=120')->everyMinute()->withoutOverlapping();
}
......
<?php
namespace App\Models\Gameshow;
use Illuminate\Database\Eloquent\Model;
class Answer extends Model
{
protected $table = 'answers';
public function question()
{
return $this->belongsTo('App\Models\Gameshow\Question','question_id','id');
}
}
<?php
namespace App\Models\Gameshow;
use Illuminate\Database\Eloquent\Model;
class Question extends Model
{
protected $table = 'questions';
public function topics()
{
return $this->belongsToMany(
'App\Models\Gameshow\Topic',
'question_topic',
'question_id',
'topic_id'
);
}
public function answers()
{
return $this->hasMany('App\Models\Gameshow\Answer', 'question_id', 'id');
}
}
<?php
namespace App\Models\Gameshow;
use Illuminate\Database\Eloquent\Model;
class Topic extends Model
{
protected $table = 'topics';
public function topics()
{
return $this->belongsToMany(
'App\Models\Gameshow\Question',
'question_topic',
'topic_id',
'question_id'
);
}
}
......@@ -170,7 +170,7 @@ return [
Yangqi\Htmldom\HtmldomServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
Ixudra\Curl\CurlServiceProvider::class,
//Alaouy\Youtube\YoutubeServiceProvider::class,
Alaouy\Youtube\YoutubeServiceProvider::class,
/*
* Application Service Providers...
......@@ -234,7 +234,7 @@ return [
'Htmldom' => Yangqi\Htmldom\Htmldom::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
'Curl' => Ixudra\Curl\Facades\Curl::class,
//'Youtube' => Alaouy\Youtube\Facades\Youtube::class,
'Youtube' => Alaouy\Youtube\Facades\Youtube::class,
],
......
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