Added custom commands.

main
Giò 2024-04-13 11:05:22 +02:00
parent 83ecfa4593
commit 9131a01b37
2 changed files with 25 additions and 5 deletions

View File

@ -2,6 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Scraper\Edomizil;
use Illuminate\Console\Command; use Illuminate\Console\Command;
class scrapeProperty extends Command class scrapeProperty extends Command
@ -18,13 +19,20 @@ class scrapeProperty extends Command
* *
* @var string * @var string
*/ */
protected $description = 'Scrapes for properties from seed'; protected $description = 'Scrapes for properties from seeds.';
/** /**
* Execute the console command. * Execute the console command.
*/ */
public function handle() public function handle()
{ {
$seeds = Edomizil::getAllSeeds();
foreach($seeds as $seed){
Edomizil::ScrapeProperty($seed);
}
$this->info('Scraping was successfull.');
} }
} }

View File

@ -2,6 +2,8 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Scraper\Edomizil;
use App\Models\Property;
use Illuminate\Console\Command; use Illuminate\Console\Command;
class scrapePropertyDate extends Command class scrapePropertyDate extends Command
@ -11,20 +13,30 @@ class scrapePropertyDate extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'scrape:propertydata'; protected $signature = 'scrape:propertydata {propertyId?}';
/** /**
* The console command description. * The console command description.
* *
* @var string * @var string
*/ */
protected $description = 'Scrapes for property data from properties.'; protected $description = 'Scrapes the data from one random property or property with ID from argument.';
/** /**
* Execute the console command. * Execute the console command.
*/ */
public function handle() 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.');
} }
} }