ConsultancyProject1_Auslast.../scraper/app/Console/Commands/scrapePropertyDate.php

43 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Scraper\Edomizil;
use App\Models\Property;
use Illuminate\Console\Command;
class scrapePropertyDate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'scrape:propertydata {propertyId?}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Scrapes the data from one random property or property with ID from argument.';
/**
* Execute the console command.
*/
public function handle()
{
$propertyId = $this->argument('propertyId');
if($propertyId && is_numeric($propertyId)){
$property = Property::select('id','property_platform_id')->where('id', 'like', $propertyId)->get();
}else{
$property = Property::select('id','property_platform_id')->inRandomOrder()->take(1)->get();
}
Edomizil::scrapePropertyData($property[0]);
$this->info('Scraping for property '.$property[0]->property_platform_id.' has ended.');
}
}