-
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.
Merge pull request #56 from bildvitta/feature/brands
Gerenciamento de marcas
- Loading branch information
Showing
25 changed files
with
159 additions
and
30 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
26 changes: 26 additions & 0 deletions
26
src/Console/Commands/DataImport/Hub/Resources/BrandImport.php
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,26 @@ | ||
<?php | ||
|
||
namespace BildVitta\SpHub\Console\Commands\DataImport\Hub\Resources; | ||
|
||
class BrandImport | ||
{ | ||
public function import(\stdClass $brand): void | ||
{ | ||
$brandModelFromConfig = app(config('hub.model_brand')); | ||
|
||
$permissionModel = $brandModelFromConfig::where('uuid', $brand->uuid) | ||
->first(); | ||
|
||
if (! $permissionModel) { | ||
$permissionModel = new $brandModelFromConfig; | ||
} | ||
|
||
$permissionModel->uuid = $brand->uuid; | ||
$permissionModel->name = $brand->name; | ||
$permissionModel->created_at = $brand->created_at; | ||
$permissionModel->updated_at = $brand->updated_at; | ||
$permissionModel->deleted_at = $brand->deleted_at; | ||
|
||
$permissionModel->save(); | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
src/Console/Commands/DataImport/Hub/Resources/DbHubBrand.php
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,26 @@ | ||
<?php | ||
|
||
namespace BildVitta\SpHub\Console\Commands\DataImport\Hub\Resources; | ||
|
||
use Illuminate\Support\Facades\DB; | ||
|
||
class DbHubBrand | ||
{ | ||
public function totalRecords(): int | ||
{ | ||
$query = 'SELECT count(1) as total FROM brands'; | ||
$result = DB::connection('sp_hub')->select($query); | ||
|
||
return (int) $result[0]->total; | ||
} | ||
|
||
public function getBrands(int $limit, int $offset): array | ||
{ | ||
$query = 'SELECT b.* FROM brands b LIMIT :limit OFFSET :offset'; | ||
|
||
return DB::connection('sp_hub')->select($query, [ | ||
'limit' => $limit, | ||
'offset' => $offset, | ||
]); | ||
} | ||
} |
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
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
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
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
28 changes: 28 additions & 0 deletions
28
src/Console/Commands/Messages/Resources/Helpers/BrandsHelper.php
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,28 @@ | ||
<?php | ||
|
||
namespace BildVitta\SpHub\Console\Commands\Messages\Resources\Helpers; | ||
|
||
use BildVitta\Hub\Entities\HubBrand; | ||
|
||
trait BrandsHelper | ||
{ | ||
protected function brandCreateOrUpdate(\stdClass $message) | ||
{ | ||
if (! $brand = HubBrand::withTrashed()->where('uuid', $message->uuid)->first()) { | ||
$brand = new HubBrand; | ||
$brand->uuid = $message->uuid; | ||
} | ||
|
||
$brand->name = $message->name; | ||
$brand->created_at = $message->created_at; | ||
$brand->updated_at = $message->updated_at; | ||
$brand->deleted_at = $message->deleted_at; | ||
|
||
$brand->save(); | ||
} | ||
|
||
protected function brandDelete(\stdClass $message) | ||
{ | ||
HubBrand::where('uuid', $message->uuid)->delete(); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.