PHP code example of rhishi-kesh / quick-talk

1. Go to this page and download the library: Download rhishi-kesh/quick-talk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rhishi-kesh / quick-talk example snippets


composer 

php artisan install:quicktalk

$table->string('avatar')->nullable();

database/seeders/DatabaseSeeder.php

$this->call(UserSeeder::class);

php artisan migrate
php artisan db:seed

php artisan storage:link

->withRouting(
    api: __DIR__ . '/../routes/api.php',
    channels: __DIR__ . '/../routes/channels.php',
    then: function () {
        Route::middleware('api')
            ->prefix('api')
            ->group(base_path('routes/chat_auth.php'));

        Route::middleware('api')
            ->prefix('api')
            ->group(base_path('routes/chat.php'));
    }
)

->withBroadcasting(__DIR__ . '/../routes/channels.php', ['prefix' => 'api', 'middleware' => ['auth:sanctum']],)

use Laravel\Sanctum\HasApiTokens;

use HasApiTokens;

use Illuminate\Support\Str;

protected $fillable = [
    'name',
    'email',
    'password',
    'avatar',
];

public function initials(): string
{
    return Str::of($this->name)
        ->explode(' ')
        ->take(2)
        ->map(fn($word) => Str::substr($word, 0, 1))
        ->implode('');
}

// Messages sent by this user
    public function sentMessages()
    {
        return $this->hasMany(Message::class, 'sender_id');
    }

    // Messages received by this user (for direct/private chats only)
    public function receivedMessages()
    {
        return $this->hasMany(Message::class, 'receiver_id');
    }

    // Conversations where user is a participant
    public function participants()
    {
        return $this->morphMany(Participant::class, 'participant');
    }

    // Conversations where user is a participant (through Participant model)
    public function conversations()
    {
        return $this->hasManyThrough(
            Conversation::class,
            Participant::class,
            'participant_id', // Foreign key on Participant table
            'id',             // Local key on Conversation table
            'id',             // Local key on User table
            'conversation_id' // Foreign key on Participant table
        )->where('participant_type', self::class);
    }

    // Message reactions made by this user
    public function messageReactions()
    {
        return $this->hasMany(MessageReaction::class);
    }

    // Read/delivery status records
    public function messageStatuses()
    {
        return $this->hasMany(MessageStatus::class);
    }

    // Firebase tokens for push notifications
    public function firebaseTokens()
    {
        return $this->hasOne(FirebaseToken::class);
    }

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=

php artisan serve

npm run dev

php artisan reverb:start