Skip to content

Commit

Permalink
chat option stub added
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Dec 3, 2023
1 parent 80a6fdc commit 8b8e480
Show file tree
Hide file tree
Showing 49 changed files with 2,991 additions and 22 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"php": "^8.1",
"fintech/core": "*",
"illuminate/contracts": "^10.0",
"owen-it/laravel-auditing": "^13.5"
"owen-it/laravel-auditing": "^13.5",
"spatie/laravel-medialibrary": "^10.13"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand Down Expand Up @@ -69,4 +70,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
36 changes: 36 additions & 0 deletions config/chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,36 @@

'root_prefix' => 'test/',


/*
|--------------------------------------------------------------------------
| ChatGroup Model
|--------------------------------------------------------------------------
|
| This value will be used to across system where model is needed
*/
'chat_group_model' => \Fintech\Chat\Models\ChatGroup::class,


/*
|--------------------------------------------------------------------------
| ChatParticipant Model
|--------------------------------------------------------------------------
|
| This value will be used to across system where model is needed
*/
'chat_participant_model' => \Fintech\Chat\Models\ChatParticipant::class,


/*
|--------------------------------------------------------------------------
| ChatMessage Model
|--------------------------------------------------------------------------
|
| This value will be used to across system where model is needed
*/
'chat_message_model' => \Fintech\Chat\Models\ChatMessage::class,

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

/*
Expand All @@ -35,6 +65,12 @@
*/

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

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

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

//** Repository Binding Config Point Do not Remove **//
],

Expand Down
37 changes: 37 additions & 0 deletions database/migrations/2023_12_03_194233_create_chat_groups_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('chat_groups', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('link')->nullable();
$table->string('type')->default('direct');
$table->json('chat_group_data')->nullable();
$table->foreignId('creator_id')->nullable();
$table->foreignId('editor_id')->nullable();
$table->foreignId('destroyer_id')->nullable();
$table->foreignId('restorer_id')->nullable();
$table->timestamps();
$table->softDeletes();
$table->timestamp('restored_at')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('chat_groups');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('chat_participants', function (Blueprint $table) {
$table->id();
$table->foreignId('chart_group_id');
$table->morphs('model');
$table->boolean('enabled')->default(true);
$table->json('chat_participant_data')->nullable();
$table->foreignId('creator_id')->nullable();
$table->foreignId('editor_id')->nullable();
$table->foreignId('destroyer_id')->nullable();
$table->foreignId('restorer_id')->nullable();
$table->timestamps();
$table->softDeletes();
$table->timestamp('restored_at')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('chat_participants');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('chat_messages', function (Blueprint $table) {
$table->id();
$table->foreignId('chat_group_id');
$table->foreignId('chat_participant_id');
$table->longText('content');
$table->json('chat_messages_data')->nullable();
$table->foreignId('creator_id')->nullable();
$table->foreignId('editor_id')->nullable();
$table->foreignId('destroyer_id')->nullable();
$table->foreignId('restorer_id')->nullable();
$table->timestamps();
$table->softDeletes();
$table->timestamp('restored_at')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('chat_messages');
}
};
19 changes: 0 additions & 19 deletions database/migrations/create_chat_table.php.stub

This file was deleted.

11 changes: 10 additions & 1 deletion routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
if (Config::get('fintech.chat.enabled')) {
Route::prefix('chat')->name('chat.')->group(function () {

//DO NOT REMOVE THIS LINE//
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-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-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');

//DO NOT REMOVE THIS LINE//
});
}
27 changes: 27 additions & 0 deletions src/Chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,32 @@

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

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

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

//** Crud Service Method Point Do not Remove **//



}
3 changes: 3 additions & 0 deletions src/Facades/Chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
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()
* // Crud Service Method Point Do not Remove //
*
* @see \Fintech\Chat\Chat
Expand Down
Loading

0 comments on commit 8b8e480

Please sign in to comment.