23 lines
509 B
PHP
23 lines
509 B
PHP
<?php
|
|
|
|
namespace App\Actions;
|
|
|
|
use App\Models\User;
|
|
use DB;
|
|
|
|
final readonly class CreateOrGetInbox
|
|
{
|
|
/**
|
|
* @return array<string, int>
|
|
*/
|
|
public function execute(User $recipient, User $sender): array
|
|
{
|
|
$chatExists = DB::table('inbox_user as sender')
|
|
->join('inbox_user as recipient', 'sender.inbox_id', '=', 'recipient.inbox_id')
|
|
->where('sender.user_id', $sender->id)
|
|
->where('recipient.user_id', $recipient->id)
|
|
->get();
|
|
|
|
}
|
|
}
|