first commit
This commit is contained in:
26
app/Jobs/ExampleJob.php
Normal file
26
app/Jobs/ExampleJob.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
class ExampleJob extends Job
|
||||
{
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
24
app/Jobs/Job.php
Normal file
24
app/Jobs/Job.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
abstract class Job implements ShouldQueue
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queueable Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This job base class provides a central location to place any logic that
|
||||
| is shared across all of your jobs. The trait included with the class
|
||||
| provides access to the "queueOn" and "delay" queue helper methods.
|
||||
|
|
||||
*/
|
||||
|
||||
use InteractsWithQueue, Queueable, SerializesModels;
|
||||
}
|
||||
37
app/Jobs/PropertyCatalogServiceJob.php
Normal file
37
app/Jobs/PropertyCatalogServiceJob.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class PropertyCatalogServiceJob extends Job
|
||||
{
|
||||
protected $propertyId;
|
||||
protected $language;
|
||||
protected $email;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct($propertyId, $language, $email = null)
|
||||
{
|
||||
$this->propertyId = $propertyId;
|
||||
$this->language = $language;
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
chdir(base_path());
|
||||
|
||||
Artisan::call('cron:property-catalog-service', [
|
||||
'property_id' => $this->propertyId,
|
||||
'language' => $this->language,
|
||||
'--email' => $this->email,
|
||||
]);
|
||||
}
|
||||
}
|
||||
32
app/Jobs/PropertyReviewAnalyzeServiceJob.php
Normal file
32
app/Jobs/PropertyReviewAnalyzeServiceJob.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class PropertyReviewAnalyzeServiceJob implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue;
|
||||
|
||||
protected $reviewId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct($reviewId)
|
||||
{
|
||||
$this->reviewId = $reviewId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Artisan::call('cron:property-review-analyze-service', [
|
||||
'review_id' => $this->reviewId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
35
app/Jobs/PropertyReviewServiceJob.php
Normal file
35
app/Jobs/PropertyReviewServiceJob.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class PropertyReviewServiceJob implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue;
|
||||
|
||||
protected $propertyId;
|
||||
protected $channelId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct($propertyId, $channelId)
|
||||
{
|
||||
$this->propertyId = $propertyId;
|
||||
$this->channelId = $channelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Artisan::call('cron:property-review-service', [
|
||||
'property_id' => $this->propertyId,
|
||||
'channel_id' => $this->channelId
|
||||
]);
|
||||
}
|
||||
}
|
||||
52
app/Jobs/SlackLogJob.php
Normal file
52
app/Jobs/SlackLogJob.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class SlackLogJob extends Job
|
||||
{
|
||||
|
||||
protected $slack;
|
||||
|
||||
public $tries = 1;
|
||||
public $timeout = 60;
|
||||
|
||||
public function __construct($slack)
|
||||
{
|
||||
$this->slack = $slack;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
|
||||
$client = new Client();
|
||||
$client->request('POST', config('app.log_slack'),
|
||||
[
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
'body' => json_encode($this->slack),
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error('--SlackLogJob RequestException--');
|
||||
Log::error($message);
|
||||
} catch (RequestException $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error('--SlackLogJob RequestException--');
|
||||
Log::error($message);
|
||||
} catch (ApiErrorException $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error('--SlackLogJob ApiErrorException--');
|
||||
Log::error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user