51 lines
1.4 KiB
PHP
51 lines
1.4 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?} {--seed=}';
|
|
|
|
/**
|
|
* 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');
|
|
$seed = $this->option('seed');
|
|
|
|
if($seed){
|
|
|
|
$property = Property::select('id','property_platform_id')->where('seed_id', $seed)->inRandomOrder()->take(1)->get();
|
|
|
|
} else {
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
$data = Edomizil::scrapePropertyData($property[0]);
|
|
$this->info('Scraping for property '.$property[0]->property_platform_id.' has ended. Here is the result: '.$data);
|
|
|
|
}
|
|
}
|