protected$description='Stores cached clicks on affiliate links into DB.';
/**
* Create a new command instance.
*
* @return void
*/
publicfunction__construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
publicfunctionhandle()
{
AdgoalController::storePartnerCalls();
# Remove old entries
# The duration in hours for entries to last is defined as constant in AdgoalController
DB::delete("delete from affiliate_clicks where created_at < DATE_SUB(NOW(), INTERVAL ? HOUR);",[\App\Http\Controllers\AdgoalController::STORAGE_DURATION_HOURS]);
$total=DB::select("select count(*) as total_rows from affiliate_blacklist where blacklist = ?",[$blacklist]);
$total=intval($total[0]->{"total_rows"});
$blacklistItems=DB::select('select * from affiliate_blacklist where blacklist = ? order by created_at desc limit ? offset ?',[$blacklist,$count,$skip]);
$result=[
"count"=>$count,
"skip"=>$skip,
"total"=>$total,
"results"=>$blacklistItems
];
returnresponse()->json($result);
}
publicfunctionaddblacklistJson(Request$request)
{
$validator=Validator::make($request->all(),[
"hostname"=>[
"required",
function($attribute,$value,$fail)use($request){
# Validate that this is indeed a hostname which is resolvable