Skip to content

Commit

Permalink
code formatted and optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Feb 26, 2024
1 parent d3e7180 commit 530d336
Show file tree
Hide file tree
Showing 47 changed files with 207 additions and 169 deletions.
19 changes: 13 additions & 6 deletions config/chat.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<?php

// config for Fintech/Chat
use Fintech\Chat\Models\ChatGroup;
use Fintech\Chat\Models\ChatMessage;
use Fintech\Chat\Models\ChatParticipant;
use Fintech\Chat\Repositories\Eloquent\ChatGroupRepository;
use Fintech\Chat\Repositories\Eloquent\ChatMessageRepository;
use Fintech\Chat\Repositories\Eloquent\ChatParticipantRepository;

return [

/*
Expand Down Expand Up @@ -31,7 +38,7 @@
|
| This value will be used to across system where model is needed
*/
'chat_group_model' => \Fintech\Chat\Models\ChatGroup::class,
'chat_group_model' => ChatGroup::class,

/*
|--------------------------------------------------------------------------
Expand All @@ -40,7 +47,7 @@
|
| This value will be used to across system where model is needed
*/
'chat_participant_model' => \Fintech\Chat\Models\ChatParticipant::class,
'chat_participant_model' => ChatParticipant::class,

/*
|--------------------------------------------------------------------------
Expand All @@ -49,7 +56,7 @@
|
| This value will be used to across system where model is needed
*/
'chat_message_model' => \Fintech\Chat\Models\ChatMessage::class,
'chat_message_model' => ChatMessage::class,

//** Model Config Point Do not Remove **//

Expand All @@ -62,11 +69,11 @@
*/

'repositories' => [
\Fintech\Chat\Interfaces\ChatGroupRepository::class => \Fintech\Chat\Repositories\Eloquent\ChatGroupRepository::class,
\Fintech\Chat\Interfaces\ChatGroupRepository::class => ChatGroupRepository::class,

\Fintech\Chat\Interfaces\ChatParticipantRepository::class => \Fintech\Chat\Repositories\Eloquent\ChatParticipantRepository::class,
\Fintech\Chat\Interfaces\ChatParticipantRepository::class => ChatParticipantRepository::class,

\Fintech\Chat\Interfaces\ChatMessageRepository::class => \Fintech\Chat\Repositories\Eloquent\ChatMessageRepository::class,
\Fintech\Chat\Interfaces\ChatMessageRepository::class => ChatMessageRepository::class,

//** Repository Binding Config Point Do not Remove **//
],
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
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
15 changes: 9 additions & 6 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use Fintech\Chat\Http\Controllers\ChatGroupController;
use Fintech\Chat\Http\Controllers\ChatMessageController;
use Fintech\Chat\Http\Controllers\ChatParticipantController;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Route;

Expand All @@ -16,14 +19,14 @@
if (Config::get('fintech.chat.enabled')) {
Route::prefix('chat')->name('chat.')->group(function () {

Route::apiResource('chat-groups', \Fintech\Chat\Http\Controllers\ChatGroupController::class);
Route::post('chat-groups/{chat_group}/restore', [\Fintech\Chat\Http\Controllers\ChatGroupController::class, 'restore'])->name('chat-groups.restore');
Route::apiResource('chat-groups', ChatGroupController::class);
Route::post('chat-groups/{chat_group}/restore', [ChatGroupController::class, 'restore'])->name('chat-groups.restore');

Route::apiResource('chat-participants', \Fintech\Chat\Http\Controllers\ChatParticipantController::class);
Route::post('chat-participants/{chat_participant}/restore', [\Fintech\Chat\Http\Controllers\ChatParticipantController::class, 'restore'])->name('chat-participants.restore');
Route::apiResource('chat-participants', ChatParticipantController::class);
Route::post('chat-participants/{chat_participant}/restore', [ChatParticipantController::class, 'restore'])->name('chat-participants.restore');

Route::apiResource('chat-messages', \Fintech\Chat\Http\Controllers\ChatMessageController::class);
Route::post('chat-messages/{chat_message}/restore', [\Fintech\Chat\Http\Controllers\ChatMessageController::class, 'restore'])->name('chat-messages.restore');
Route::apiResource('chat-messages', ChatMessageController::class);
Route::post('chat-messages/{chat_message}/restore', [ChatMessageController::class, 'restore'])->name('chat-messages.restore');

//DO NOT REMOVE THIS LINE//
});
Expand Down
16 changes: 10 additions & 6 deletions src/Chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,34 @@

namespace Fintech\Chat;

use Fintech\Chat\Services\ChatGroupService;
use Fintech\Chat\Services\ChatMessageService;
use Fintech\Chat\Services\ChatParticipantService;

class Chat
{
/**
* @return \Fintech\Chat\Services\ChatGroupService
* @return ChatGroupService
*/
public function chatGroup()
{
return app(\Fintech\Chat\Services\ChatGroupService::class);
return app(ChatGroupService::class);
}

/**
* @return \Fintech\Chat\Services\ChatParticipantService
* @return ChatParticipantService
*/
public function chatParticipant()
{
return app(\Fintech\Chat\Services\ChatParticipantService::class);
return app(ChatParticipantService::class);
}

/**
* @return \Fintech\Chat\Services\ChatMessageService
* @return ChatMessageService
*/
public function chatMessage()
{
return app(\Fintech\Chat\Services\ChatMessageService::class);
return app(ChatMessageService::class);
}

//** Crud Service Method Point Do not Remove **//
Expand Down
14 changes: 7 additions & 7 deletions src/ChatServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ChatServiceProvider extends ServiceProvider
public function register()
{
$this->mergeConfigFrom(
__DIR__.'/../config/chat.php', 'fintech.chat'
__DIR__ . '/../config/chat.php', 'fintech.chat'
);

$this->app->register(RouteServiceProvider::class);
Expand All @@ -29,21 +29,21 @@ public function register()
public function boot(): void
{
$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
9 changes: 6 additions & 3 deletions src/Facades/Chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

namespace Fintech\Chat\Facades;

use Fintech\Chat\Services\ChatGroupService;
use Fintech\Chat\Services\ChatMessageService;
use Fintech\Chat\Services\ChatParticipantService;
use Illuminate\Support\Facades\Facade;

/**
* @method static \Fintech\Chat\Services\ChatGroupService chatGroup()
* @method static \Fintech\Chat\Services\ChatParticipantService chatParticipant()
* @method static \Fintech\Chat\Services\ChatMessageService chatMessage()
* @method static ChatGroupService chatGroup()
* @method static ChatParticipantService chatParticipant()
* @method static ChatMessageService chatMessage()
* // Crud Service Method Point Do not Remove //
*
* @see \Fintech\Chat\Chat
Expand Down
16 changes: 8 additions & 8 deletions src/Http/Controllers/ChatGroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function store(StoreChatGroupRequest $request): JsonResponse

$chatGroup = Chat::chatGroup()->create($inputs);

if (! $chatGroup) {
if (!$chatGroup) {
throw (new StoreOperationException)->setModel(config('fintech.chat.chat_group_model'));
}

Expand Down Expand Up @@ -99,7 +99,7 @@ public function show(string|int $id): ChatGroupResource|JsonResponse

$chatGroup = Chat::chatGroup()->find($id);

if (! $chatGroup) {
if (!$chatGroup) {
throw (new ModelNotFoundException)->setModel(config('fintech.chat.chat_group_model'), $id);
}

Expand Down Expand Up @@ -130,13 +130,13 @@ public function update(UpdateChatGroupRequest $request, string|int $id): JsonRes

$chatGroup = Chat::chatGroup()->find($id);

if (! $chatGroup) {
if (!$chatGroup) {
throw (new ModelNotFoundException)->setModel(config('fintech.chat.chat_group_model'), $id);
}

$inputs = $request->validated();

if (! Chat::chatGroup()->update($id, $inputs)) {
if (!Chat::chatGroup()->update($id, $inputs)) {

throw (new UpdateOperationException)->setModel(config('fintech.chat.chat_group_model'), $id);
}
Expand Down Expand Up @@ -170,11 +170,11 @@ public function destroy(string|int $id)

$chatGroup = Chat::chatGroup()->find($id);

if (! $chatGroup) {
if (!$chatGroup) {
throw (new ModelNotFoundException)->setModel(config('fintech.chat.chat_group_model'), $id);
}

if (! Chat::chatGroup()->destroy($id)) {
if (!Chat::chatGroup()->destroy($id)) {

throw (new DeleteOperationException())->setModel(config('fintech.chat.chat_group_model'), $id);
}
Expand Down Expand Up @@ -206,11 +206,11 @@ public function restore(string|int $id)

$chatGroup = Chat::chatGroup()->find($id, true);

if (! $chatGroup) {
if (!$chatGroup) {
throw (new ModelNotFoundException)->setModel(config('fintech.chat.chat_group_model'), $id);
}

if (! Chat::chatGroup()->restore($id)) {
if (!Chat::chatGroup()->restore($id)) {

throw (new RestoreOperationException())->setModel(config('fintech.chat.chat_group_model'), $id);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Http/Controllers/ChatMessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function store(StoreChatMessageRequest $request): JsonResponse

$chatMessage = Chat::chatMessage()->create($inputs);

if (! $chatMessage) {
if (!$chatMessage) {
throw (new StoreOperationException)->setModel(config('fintech.chat.chat_message_model'));
}

Expand Down Expand Up @@ -99,7 +99,7 @@ public function show(string|int $id): ChatMessageResource|JsonResponse

$chatMessage = Chat::chatMessage()->find($id);

if (! $chatMessage) {
if (!$chatMessage) {
throw (new ModelNotFoundException)->setModel(config('fintech.chat.chat_message_model'), $id);
}

Expand Down Expand Up @@ -130,13 +130,13 @@ public function update(UpdateChatMessageRequest $request, string|int $id): JsonR

$chatMessage = Chat::chatMessage()->find($id);

if (! $chatMessage) {
if (!$chatMessage) {
throw (new ModelNotFoundException)->setModel(config('fintech.chat.chat_message_model'), $id);
}

$inputs = $request->validated();

if (! Chat::chatMessage()->update($id, $inputs)) {
if (!Chat::chatMessage()->update($id, $inputs)) {

throw (new UpdateOperationException)->setModel(config('fintech.chat.chat_message_model'), $id);
}
Expand Down Expand Up @@ -170,11 +170,11 @@ public function destroy(string|int $id)

$chatMessage = Chat::chatMessage()->find($id);

if (! $chatMessage) {
if (!$chatMessage) {
throw (new ModelNotFoundException)->setModel(config('fintech.chat.chat_message_model'), $id);
}

if (! Chat::chatMessage()->destroy($id)) {
if (!Chat::chatMessage()->destroy($id)) {

throw (new DeleteOperationException())->setModel(config('fintech.chat.chat_message_model'), $id);
}
Expand Down Expand Up @@ -206,11 +206,11 @@ public function restore(string|int $id)

$chatMessage = Chat::chatMessage()->find($id, true);

if (! $chatMessage) {
if (!$chatMessage) {
throw (new ModelNotFoundException)->setModel(config('fintech.chat.chat_message_model'), $id);
}

if (! Chat::chatMessage()->restore($id)) {
if (!Chat::chatMessage()->restore($id)) {

throw (new RestoreOperationException())->setModel(config('fintech.chat.chat_message_model'), $id);
}
Expand Down
Loading

0 comments on commit 530d336

Please sign in to comment.