-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accessories and blueprints observers
- Loading branch information
1 parent
c5121bf
commit ea43992
Showing
5 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Bildvitta\IssSupernova\Observers\RealEstateDevelopment; | ||
|
||
use Bildvitta\IssSupernova\IssSupernova; | ||
use Illuminate\Support\Facades\App; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class AccessoryObserver | ||
{ | ||
public function created($accessory) | ||
{ | ||
if (!Config::get('iss-supernova.base_uri')) { | ||
return; | ||
} | ||
|
||
$accessory->loadMissing( | ||
'real_estate_development', | ||
'accessory' | ||
); | ||
if ($accessory->real_estate_development) { | ||
$accessory->real_estate_development->loadMissing( | ||
'blueprints' | ||
); | ||
} | ||
|
||
$data = $accessory->toArray(); | ||
$data['sync_to'] = 'sys'; | ||
|
||
try { | ||
$issSupernova = new IssSupernova(); | ||
$response = $issSupernova->realEstateDevelopmentAccessories()->create($data); | ||
return $response; | ||
} catch (\Throwable $exception) { | ||
Log::error($exception->getMessage()); | ||
throw $exception; | ||
} | ||
} | ||
|
||
public function updated($accessory) | ||
{ | ||
if (!Config::get('iss-supernova.base_uri')) { | ||
return; | ||
} | ||
|
||
$accessory->loadMissing( | ||
'real_estate_development', | ||
'accessory' | ||
); | ||
if ($accessory->real_estate_development) { | ||
$accessory->real_estate_development->loadMissing( | ||
'blueprints' | ||
); | ||
} | ||
|
||
$data = $accessory->toArray(); | ||
$data['sync_to'] = 'sys'; | ||
|
||
try { | ||
$issSupernova = new IssSupernova(); | ||
$response = $issSupernova->realEstateDevelopmentAccessories()->update($data); | ||
return $response; | ||
} catch (\Throwable $exception) { | ||
Log::error($exception->getMessage()); | ||
throw $exception; | ||
} | ||
} | ||
|
||
public function deleted($accessory) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Bildvitta\IssSupernova\Observers\RealEstateDevelopment; | ||
|
||
use Bildvitta\IssSupernova\IssSupernova; | ||
use Illuminate\Support\Facades\App; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class BlueprintObserver | ||
{ | ||
public function created($blueprint) | ||
{ | ||
if (!Config::get('iss-supernova.base_uri')) { | ||
return; | ||
} | ||
|
||
$blueprint->loadMissing('real_estate_development'); | ||
|
||
$data = $blueprint->toArray(); | ||
$data['sync_to'] = 'sys'; | ||
|
||
try { | ||
$issSupernova = new IssSupernova(); | ||
$response = $issSupernova->realEstateDevelopmentBlueprints()->create($data); | ||
return $response; | ||
} catch (\Throwable $exception) { | ||
Log::error($exception->getMessage()); | ||
throw $exception; | ||
} | ||
} | ||
|
||
public function updated($blueprint) | ||
{ | ||
if (!Config::get('iss-supernova.base_uri')) { | ||
return; | ||
} | ||
|
||
$blueprint->loadMissing('real_estate_development'); | ||
|
||
$data = $blueprint->toArray(); | ||
$data['sync_to'] = 'sys'; | ||
|
||
try { | ||
$issSupernova = new IssSupernova(); | ||
$response = $issSupernova->realEstateDevelopmentBlueprints()->update($data); | ||
return $response; | ||
} catch (\Throwable $exception) { | ||
Log::error($exception->getMessage()); | ||
throw $exception; | ||
} | ||
} | ||
|
||
public function deleted($blueprint) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Bildvitta\IssSupernova\Resources; | ||
|
||
use Bildvitta\IssSupernova\IssSupernova; | ||
|
||
class RealEstateDevelopmentAccessories | ||
{ | ||
private IssSupernova $issSupernova; | ||
|
||
public function __construct(IssSupernova $issSupernova) | ||
{ | ||
$this->issSupernova = $issSupernova; | ||
} | ||
|
||
public function create($data) | ||
{ | ||
return $this->issSupernova->request->post( | ||
'/real-estate-developments/accessories', | ||
$data | ||
)->throw()->object(); | ||
} | ||
|
||
public function update($data) | ||
{ | ||
return $this->issSupernova->request->put( | ||
'/real-estate-developments/accessories', | ||
$data | ||
)->throw()->object(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Bildvitta\IssSupernova\Resources; | ||
|
||
use Bildvitta\IssSupernova\IssSupernova; | ||
|
||
class RealEstateDevelopmentBlueprints | ||
{ | ||
private IssSupernova $issSupernova; | ||
|
||
public function __construct(IssSupernova $issSupernova) | ||
{ | ||
$this->issSupernova = $issSupernova; | ||
} | ||
|
||
public function create($data) | ||
{ | ||
return $this->issSupernova->request->post( | ||
'/real-estate-developments/blueprints', | ||
$data | ||
)->throw()->object(); | ||
} | ||
|
||
public function update($data) | ||
{ | ||
return $this->issSupernova->request->put( | ||
'/real-estate-developments/blueprints', | ||
$data | ||
)->throw()->object(); | ||
} | ||
} |