Skip to content

Commit

Permalink
code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Aug 31, 2024
1 parent f9cc1fb commit 80b6848
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 27 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
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
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
14 changes: 7 additions & 7 deletions src/ChatServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -35,21 +35,21 @@ 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->publishes([
__DIR__.'/../resources/views' => resource_path('views/vendor/chat'),
__DIR__ . '/../resources/views' => resource_path('views/vendor/chat'),
]);

if ($this->app->runningInConsole()) {
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/ChatException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/ChatGroupRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/ChatMessageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/ChatParticipantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/Eloquent/ChatGroupRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/Eloquent/ChatMessageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/Eloquent/ChatParticipantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/Repositories/Mongodb/ChatGroupRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check failure on line 22 in src/Repositories/Mongodb/ChatGroupRepository.php

View workflow job for this annotation

GitHub Actions / phpstan

Class MongoDB\Laravel\Eloquent\Model not found.
throw new InvalidArgumentException("Mongodb repository require model class to be `MongoDB\Laravel\Eloquent\Model` instance.");
}

Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/Repositories/Mongodb/ChatMessageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check failure on line 22 in src/Repositories/Mongodb/ChatMessageRepository.php

View workflow job for this annotation

GitHub Actions / phpstan

Class MongoDB\Laravel\Eloquent\Model not found.
throw new InvalidArgumentException("Mongodb repository require model class to be `MongoDB\Laravel\Eloquent\Model` instance.");
}

Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/Repositories/Mongodb/ChatParticipantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check failure on line 22 in src/Repositories/Mongodb/ChatParticipantRepository.php

View workflow job for this annotation

GitHub Actions / phpstan

Class MongoDB\Laravel\Eloquent\Model not found.
throw new InvalidArgumentException("Mongodb repository require model class to be `MongoDB\Laravel\Eloquent\Model` instance.");
}

Expand All @@ -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 {
Expand Down

0 comments on commit 80b6848

Please sign in to comment.