Commit 8eaa7c70 by Phạm Văn Đoan

fixbug

parent 3f070a6e
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Maatwebsite\Excel\Facades\Excel;
class ExportRankingCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'export:ranking {type?}';
/**
* 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()
{
Excel::create('weekly_report', function($excel) {
$excel->sheet('Sheetname', function($sheet) {
// Sheet manipulation
$sheet->cell('A1', function($cell) {
// manipulate the cell
$cell->setValue('data1');
});
/*$sheet->cells('A1:A5', function($cells) {
// manipulate the range of cells
});*/
});
})->store('xlsx', storage_path('exports/weekly_report'));
}
}
......@@ -69,9 +69,14 @@ class NctCrawlerTrackCommand extends Command
$bulk_track_insert = [];
foreach ($tracks as $key => $track) {
//$link = $this->privateGeTrackLink($tracks_playlist, $track['id_nct']);
$link = $tracks_playlist[$key]['link'];
$duration = $tracks_playlist[$key]['duration'];
$link = null;
$duration = 0;
$check = $this->privateGeTrackLink($tracks_playlist, $track['id_nct']);
if ($check) {
$link = $check['link'];
$duration = $check['duration'];
}
// Xử lý insert/update dựa vào tên bài hát
if (is_array($inserted) && count($inserted) > 0 && in_array($track['title'], $inserted)) {
// Cập nhật
......@@ -136,7 +141,7 @@ class NctCrawlerTrackCommand extends Command
if (is_array($tracks_playlist) && count($tracks_playlist) > 0) {
foreach ($tracks_playlist as $key => $val) {
if ($val['id_nct'] == $track_id) {
return $val['link'];
return $val;
}
}
}
......
......@@ -6,6 +6,7 @@ use App\Console\Commands\CalculateDailyListenCommand;
use App\Console\Commands\CalculateReportCommand;
use App\Console\Commands\CrawlerTrackListenCommand;
use App\Console\Commands\CrontjobCommand;
use App\Console\Commands\ExportRankingCommand;
use App\Console\Commands\Keeng\KeengCrawlerByCateCommand;
use App\Console\Commands\Keeng\KeengCrawlerNewRealeaseCommand;
use App\Console\Commands\Keeng\KeengCrawlerTrackCommand;
......@@ -45,6 +46,8 @@ class Kernel extends ConsoleKernel
UpdateTrackArtistCommand::class,
ExportRankingCommand::class
];
......
......@@ -9,8 +9,9 @@
"ixudra/curl": "^6.19",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"maatwebsite/excel": "~2.1.0",
"sunra/php-simple-html-dom-parser": "^1.5",
"yangqi/htmldom":"@dev"
"yangqi/htmldom": "@dev"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
......
......@@ -168,6 +168,7 @@ return [
*/
Laravel\Tinker\TinkerServiceProvider::class,
Yangqi\Htmldom\HtmldomServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
/*
* Application Service Providers...
......@@ -227,6 +228,7 @@ return [
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Htmldom' => Yangqi\Htmldom\Htmldom::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::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