2024-04-13 00:54:08 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
2024-04-13 11:05:22 +02:00
|
|
|
use App\Scraper\Edomizil;
|
|
|
|
use App\Models\Property;
|
2024-04-13 00:54:08 +02:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
class scrapePropertyDate extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2024-04-13 11:05:22 +02:00
|
|
|
protected $signature = 'scrape:propertydata {propertyId?}';
|
2024-04-13 00:54:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2024-04-13 11:05:22 +02:00
|
|
|
protected $description = 'Scrapes the data from one random property or property with ID from argument.';
|
2024-04-13 00:54:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2024-04-13 11:05:22 +02:00
|
|
|
$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.');
|
|
|
|
|
2024-04-13 00:54:08 +02:00
|
|
|
}
|
|
|
|
}
|