From 8405f929d33bbd696d83d7cade731717b500b558 Mon Sep 17 00:00:00 2001 From: Mohammad Hafijul Islam Date: Mon, 16 Sep 2024 01:49:56 +0600 Subject: [PATCH] code refactored --- ...023_12_03_194233_create_chat_groups_table.php | 3 +-- ..._03_194247_create_chat_participants_table.php | 3 +-- ...3_12_03_194256_create_chat_messages_table.php | 3 +-- src/ChatServiceProvider.php | 16 ++++++++-------- src/Exceptions/ChatException.php | 4 ++-- src/Interfaces/ChatGroupRepository.php | 2 +- src/Interfaces/ChatMessageRepository.php | 2 +- src/Interfaces/ChatParticipantRepository.php | 2 +- .../Eloquent/ChatGroupRepository.php | 2 +- .../Eloquent/ChatMessageRepository.php | 2 +- .../Eloquent/ChatParticipantRepository.php | 2 +- src/Repositories/Mongodb/ChatGroupRepository.php | 4 ++-- .../Mongodb/ChatMessageRepository.php | 4 ++-- .../Mongodb/ChatParticipantRepository.php | 4 ++-- 14 files changed, 25 insertions(+), 28 deletions(-) diff --git a/database/migrations/2023_12_03_194233_create_chat_groups_table.php b/database/migrations/2023_12_03_194233_create_chat_groups_table.php index d9afebe..db12f75 100644 --- a/database/migrations/2023_12_03_194233_create_chat_groups_table.php +++ b/database/migrations/2023_12_03_194233_create_chat_groups_table.php @@ -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. */ diff --git a/database/migrations/2023_12_03_194247_create_chat_participants_table.php b/database/migrations/2023_12_03_194247_create_chat_participants_table.php index 2343b58..bc19223 100644 --- a/database/migrations/2023_12_03_194247_create_chat_participants_table.php +++ b/database/migrations/2023_12_03_194247_create_chat_participants_table.php @@ -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. */ diff --git a/database/migrations/2023_12_03_194256_create_chat_messages_table.php b/database/migrations/2023_12_03_194256_create_chat_messages_table.php index f54ff95..facfbf2 100644 --- a/database/migrations/2023_12_03_194256_create_chat_messages_table.php +++ b/database/migrations/2023_12_03_194256_create_chat_messages_table.php @@ -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. */ diff --git a/src/ChatServiceProvider.php b/src/ChatServiceProvider.php index a8cfaa0..b77387d 100644 --- a/src/ChatServiceProvider.php +++ b/src/ChatServiceProvider.php @@ -21,7 +21,7 @@ public function register() $this->packageCode = 'chat'; $this->mergeConfigFrom( - __DIR__.'/../config/chat.php', 'fintech.chat' + __DIR__ . '/../config/chat.php', 'fintech.chat' ); $this->app->register(RepositoryServiceProvider::class); @@ -35,23 +35,23 @@ public function boot(): void $this->injectOnConfig(); $this->publishes([ - __DIR__.'/../config/chat.php' => config_path('fintech/chat.php'), + __DIR__ . '/../config/chat.php' => config_path('fintech/chat.php'), ]); - $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); - $this->loadTranslationsFrom(__DIR__.'/../lang', 'chat'); + $this->loadTranslationsFrom(__DIR__ . '/../lang', 'chat'); $this->publishes([ - __DIR__.'/../lang' => $this->app->langPath('vendor/chat'), + __DIR__ . '/../lang' => $this->app->langPath('vendor/chat'), ]); - $this->loadViewsFrom(__DIR__.'/../resources/views', 'chat'); + $this->loadViewsFrom(__DIR__ . '/../resources/views', 'chat'); - $this->loadRoutesFrom(__DIR__.'/../routes/api.php'); + $this->loadRoutesFrom(__DIR__ . '/../routes/api.php'); $this->publishes([ - __DIR__.'/../resources/views' => resource_path('views/vendor/chat'), + __DIR__ . '/../resources/views' => resource_path('views/vendor/chat'), ]); if ($this->app->runningInConsole()) { diff --git a/src/Exceptions/ChatException.php b/src/Exceptions/ChatException.php index dd8160b..8a5b824 100644 --- a/src/Exceptions/ChatException.php +++ b/src/Exceptions/ChatException.php @@ -13,8 +13,8 @@ class ChatException 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) { diff --git a/src/Interfaces/ChatGroupRepository.php b/src/Interfaces/ChatGroupRepository.php index d7d8281..580c938 100644 --- a/src/Interfaces/ChatGroupRepository.php +++ b/src/Interfaces/ChatGroupRepository.php @@ -37,7 +37,7 @@ public function update(int|string $id, array $attributes = []); /** * find and delete a entry from records * - * @param bool $onlyTrashed + * @param bool $onlyTrashed * @return BaseModel */ public function find(int|string $id, $onlyTrashed = false); diff --git a/src/Interfaces/ChatMessageRepository.php b/src/Interfaces/ChatMessageRepository.php index d950d76..0759492 100644 --- a/src/Interfaces/ChatMessageRepository.php +++ b/src/Interfaces/ChatMessageRepository.php @@ -37,7 +37,7 @@ public function update(int|string $id, array $attributes = []); /** * find and delete a entry from records * - * @param bool $onlyTrashed + * @param bool $onlyTrashed * @return BaseModel */ public function find(int|string $id, $onlyTrashed = false); diff --git a/src/Interfaces/ChatParticipantRepository.php b/src/Interfaces/ChatParticipantRepository.php index 7ad2b18..a1201a6 100644 --- a/src/Interfaces/ChatParticipantRepository.php +++ b/src/Interfaces/ChatParticipantRepository.php @@ -37,7 +37,7 @@ public function update(int|string $id, array $attributes = []); /** * find and delete a entry from records * - * @param bool $onlyTrashed + * @param bool $onlyTrashed * @return BaseModel */ public function find(int|string $id, $onlyTrashed = false); diff --git a/src/Repositories/Eloquent/ChatGroupRepository.php b/src/Repositories/Eloquent/ChatGroupRepository.php index 861e810..3cd9637 100644 --- a/src/Repositories/Eloquent/ChatGroupRepository.php +++ b/src/Repositories/Eloquent/ChatGroupRepository.php @@ -29,7 +29,7 @@ public function list(array $filters = []) $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 { diff --git a/src/Repositories/Eloquent/ChatMessageRepository.php b/src/Repositories/Eloquent/ChatMessageRepository.php index 6a0e026..3a5d21b 100644 --- a/src/Repositories/Eloquent/ChatMessageRepository.php +++ b/src/Repositories/Eloquent/ChatMessageRepository.php @@ -29,7 +29,7 @@ public function list(array $filters = []) $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 { diff --git a/src/Repositories/Eloquent/ChatParticipantRepository.php b/src/Repositories/Eloquent/ChatParticipantRepository.php index 5df8f10..1fdbd71 100644 --- a/src/Repositories/Eloquent/ChatParticipantRepository.php +++ b/src/Repositories/Eloquent/ChatParticipantRepository.php @@ -29,7 +29,7 @@ public function list(array $filters = []) $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 { diff --git a/src/Repositories/Mongodb/ChatGroupRepository.php b/src/Repositories/Mongodb/ChatGroupRepository.php index 2adfe77..c7f86ee 100644 --- a/src/Repositories/Mongodb/ChatGroupRepository.php +++ b/src/Repositories/Mongodb/ChatGroupRepository.php @@ -19,7 +19,7 @@ public function __construct() { $model = app(config('fintech.chat.chat_group_model', ChatGroup::class)); - if (! $model instanceof Model) { + if (!$model instanceof Model) { throw new InvalidArgumentException("Mongodb repository require model class to be `MongoDB\Laravel\Eloquent\Model` instance."); } @@ -37,7 +37,7 @@ public function list(array $filters = []) $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 { diff --git a/src/Repositories/Mongodb/ChatMessageRepository.php b/src/Repositories/Mongodb/ChatMessageRepository.php index 5507df9..2c93c90 100644 --- a/src/Repositories/Mongodb/ChatMessageRepository.php +++ b/src/Repositories/Mongodb/ChatMessageRepository.php @@ -19,7 +19,7 @@ public function __construct() { $model = app(config('fintech.chat.chat_message_model', ChatMessage::class)); - if (! $model instanceof Model) { + if (!$model instanceof Model) { throw new InvalidArgumentException("Mongodb repository require model class to be `MongoDB\Laravel\Eloquent\Model` instance."); } @@ -37,7 +37,7 @@ public function list(array $filters = []) $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 { diff --git a/src/Repositories/Mongodb/ChatParticipantRepository.php b/src/Repositories/Mongodb/ChatParticipantRepository.php index f8191bc..4372abf 100644 --- a/src/Repositories/Mongodb/ChatParticipantRepository.php +++ b/src/Repositories/Mongodb/ChatParticipantRepository.php @@ -19,7 +19,7 @@ public function __construct() { $model = app(config('fintech.chat.chat_participant_model', ChatParticipant::class)); - if (! $model instanceof Model) { + if (!$model instanceof Model) { throw new InvalidArgumentException("Mongodb repository require model class to be `MongoDB\Laravel\Eloquent\Model` instance."); } @@ -37,7 +37,7 @@ public function list(array $filters = []) $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 {