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

51 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace App\Console\Commands;
2024-04-13 11:05:22 +02:00
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
*/
2024-06-24 18:49:43 +02:00
protected $signature = 'scrape:propertydata {propertyId?} {--seed=}';
/**
* 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.';
/**
* Execute the console command.
*/
public function handle()
{
2024-04-13 11:05:22 +02:00
$propertyId = $this->argument('propertyId');
2024-06-24 18:49:43 +02:00
$seed = $this->option('seed');
2024-04-13 11:05:22 +02:00
2024-06-24 18:49:43 +02:00
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();
}
2024-04-13 11:05:22 +02:00
}
2024-06-24 18:49:43 +02:00
$data = Edomizil::scrapePropertyData($property[0]);
$this->info('Scraping for property '.$property[0]->property_platform_id.' has ended. Here is the result: '.$data);
2024-04-13 11:05:22 +02:00
}
}