Skip to content

Commit

Permalink
trait replaced with macro
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed May 9, 2024
1 parent c3bb77b commit 1b16834
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/PromoException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class PromoException extends Exception
/**
* CoreException constructor.
*
* @param string $message
* @param int $code
* @param string $message
* @param int $code
*/
public function __construct($message = '', $code = 0, ?Throwable $previous = null)
{
Expand Down
17 changes: 9 additions & 8 deletions src/PromoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Fintech\Core\Traits\RegisterPackageTrait;
use Fintech\Promo\Commands\InstallCommand;
use Fintech\Promo\Providers\RepositoryServiceProvider;
use Illuminate\Support\ServiceProvider;

class PromoServiceProvider extends ServiceProvider
Expand All @@ -20,10 +21,10 @@ public function register()
$this->packageCode = 'promo';

$this->mergeConfigFrom(
__DIR__.'/../config/promo.php', 'fintech.promo'
__DIR__ . '/../config/promo.php', 'fintech.promo'
);

$this->app->register(\Fintech\Promo\Providers\RepositoryServiceProvider::class);
$this->app->register(RepositoryServiceProvider::class);
}

/**
Expand All @@ -34,21 +35,21 @@ public function boot(): void
$this->injectOnConfig();

$this->publishes([
__DIR__.'/../config/promo.php' => config_path('fintech/promo.php'),
__DIR__ . '/../config/promo.php' => config_path('fintech/promo.php'),
]);

$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');

$this->loadTranslationsFrom(__DIR__.'/../lang', 'promo');
$this->loadTranslationsFrom(__DIR__ . '/../lang', 'promo');

$this->publishes([
__DIR__.'/../lang' => $this->app->langPath('vendor/promo'),
__DIR__ . '/../lang' => $this->app->langPath('vendor/promo'),
]);

$this->loadViewsFrom(__DIR__.'/../resources/views', 'promo');
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'promo');

$this->publishes([
__DIR__.'/../resources/views' => resource_path('views/vendor/promo'),
__DIR__ . '/../resources/views' => resource_path('views/vendor/promo'),
]);

if ($this->app->runningInConsole()) {
Expand Down
8 changes: 4 additions & 4 deletions src/Repositories/Eloquent/PromotionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function list(array $filters = []): Paginator|Collection
$query = $this->model->newQuery();

//Searching
if (! empty($filters['search'])) {
if (!empty($filters['search'])) {
if (is_numeric($filters['search'])) {
$query->where($this->model->getKeyName(), 'like', "%{$filters['search']}%");
} else {
Expand All @@ -37,15 +37,15 @@ public function list(array $filters = []): Paginator|Collection
}
}

if (! empty($filters['type'])) {
if (!empty($filters['type'])) {
$query->where('type', $filters['type']);
}

if (! empty($filters['present_country_id'])) {
if (!empty($filters['present_country_id'])) {
$query->where('present_country_id', $filters['present_country_id']);
}

if (! empty($filters['permanent_country_id'])) {
if (!empty($filters['permanent_country_id'])) {
$query->where('permanent_country_id', $filters['permanent_country_id']);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Repositories/Mongodb/PromotionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct()
{
$model = app(config('fintech.promo.promotion_model', Promotion::class));

if (! $model instanceof Model) {
if (!$model instanceof Model) {
throw new InvalidArgumentException("Mongodb repository require model class to be `MongoDB\Laravel\Eloquent\Model` instance.");
}

Expand All @@ -35,20 +35,20 @@ public function list(array $filters = []): Paginator|Collection
$query = $this->model->newQuery();

//Searching
if (isset($filters['search']) && ! empty($filters['search'])) {
if (isset($filters['search']) && !empty($filters['search'])) {
if (is_numeric($filters['search'])) {
$query->where($this->model->getKeyName(), 'like', "%{$filters['search']}%");
} else {
$query->where('promotion_title', 'like', "%{$filters['search']}%");
}
}

if (isset($filters['promotion_type']) && ! empty($filters['promotion_type'])) {
if (isset($filters['promotion_type']) && !empty($filters['promotion_type'])) {
$query->where('promotion_type', $filters['promotion_type']);
}

//Display Trashed
if (isset($filters['trashed']) && ! empty($filters['trashed'])) {
if (isset($filters['trashed']) && !empty($filters['trashed'])) {
$query->onlyTrashed();
}

Expand Down
1 change: 0 additions & 1 deletion tests/Feature/PromoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use Illuminate\Database\Eloquent\Model as MYSQLDBLEBUPAY;
use Illuminate\Support\Str;
use MongoDB\Laravel\Eloquent\Model as MONGODB;

use function Pest\Laravel\getJson;

function createPromotionEvent(): MYSQLDBLEBUPAY|MONGODB|null
Expand Down

0 comments on commit 1b16834

Please sign in to comment.