init
This commit is contained in:
232 files changed
+25416
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\CafeBazaar;
|
||||
|
||||
use App\Models\BazaarRelease;
|
||||
use App\Models\MobileApp;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class BazaarReleaseRecorder
|
||||
{
|
||||
public function record(MobileApp $app, string $status, BazaarResponse $response, array $attributes = []): ?BazaarRelease
|
||||
{
|
||||
if (! $response->successful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$release = BazaarRelease::query()
|
||||
->whereBelongsTo($app)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
$release ??= new BazaarRelease(['mobile_app_id' => $app->id]);
|
||||
$release->fill([
|
||||
...$attributes,
|
||||
'bazaar_release_id' => Arr::get($response->body, 'release.id', $release->bazaar_release_id),
|
||||
'status' => $status,
|
||||
'bazaar_response' => $response->body,
|
||||
]);
|
||||
$release->save();
|
||||
|
||||
return $release;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user