Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
64 lines (53 sloc) 1.23 KB
<?php
namespace ImguBox\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
use ImguBox\Jobs\FetchImages;
use ImguBox\User;
class FetchUserFavs extends Command
{
use DispatchesJobs;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'imgubox:fetchFavs';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Fetches User Favs from Imgur (Get the favorited images).';
/**
* User Instance.
*
* @var ImguBox\User
*/
protected $user;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct(User $user)
{
parent::__construct();
$this->user = $user;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info('Start fetching');
$this->user->hasDropboxToken()->hasImgurToken()->chunk(10, function ($users) {
foreach ($users as $user) {
$this->dispatch((new FetchImages($user))->onQueue('low'));
}
});
$this->info('Done');
}
}
You can’t perform that action at this time.