forked from eatvio/eatvio-infra
analysators added
This commit is contained in:
@@ -6,13 +6,11 @@ use App\Events\ChatMessageUpdated;
|
||||
use App\Models\Chat;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Faker\Factory as FakerFaktory;
|
||||
|
||||
class ChatMessage
|
||||
{
|
||||
|
||||
public $id;
|
||||
|
||||
public $payload;
|
||||
|
||||
public function __construct($id, $payload)
|
||||
@@ -38,13 +36,13 @@ class ChatMessage
|
||||
$data1 = [
|
||||
'from_user_id' => $user2,
|
||||
'to_user_id' => $user1,
|
||||
'data' => $faker->text()
|
||||
'data' => $faker->text(),
|
||||
];
|
||||
|
||||
$data2 = [
|
||||
'from_user_id' => $user1,
|
||||
'to_user_id' => $user2,
|
||||
'data' => $faker->text()
|
||||
'data' => $faker->text(),
|
||||
];
|
||||
|
||||
$newMessage = (new Chat())->forceFill($data1);
|
||||
@@ -84,7 +82,7 @@ class ChatController extends Controller
|
||||
|
||||
$lastChatRecipientUserId = $lastChatMessage->count() ? $lastChatMessage['from_user_id'] : null;
|
||||
|
||||
if (!is_null($lastChatRecipientUserId) && $lastChatMessage['from_user_id'] === $curUserId) {
|
||||
if (! is_null($lastChatRecipientUserId) && $lastChatMessage['from_user_id'] === $curUserId) {
|
||||
$lastChatRecipientUserId = $lastChatMessage['to_user_id'];
|
||||
}
|
||||
|
||||
@@ -94,7 +92,7 @@ class ChatController extends Controller
|
||||
'lastChatRecipientUserId' => $lastChatRecipientUserId,
|
||||
'lastChatUsers' => $lastChatUsers,
|
||||
'curUserId' => $curUserId,
|
||||
'chanId' => $this->makeChanName($curUserId, $lastChatRecipientUserId)
|
||||
'chanId' => $this->makeChanName($curUserId, $lastChatRecipientUserId),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -102,8 +100,8 @@ class ChatController extends Controller
|
||||
private function makeChanName($from, $to)
|
||||
{
|
||||
return (int) $from < (int) $to
|
||||
? $from. "_" . $to
|
||||
: $to . "_" . $from;
|
||||
? $from.'_'.$to
|
||||
: $to.'_'.$from;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,13 +111,12 @@ class ChatController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
ChatMessageUpdated::dispatch(new ChatMessage(time(), 'some text ' . md5(time())));
|
||||
ChatMessageUpdated::dispatch(new ChatMessage(time(), 'some text '.md5(time())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
@@ -130,7 +127,7 @@ class ChatController extends Controller
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Chat $chat
|
||||
* @param \App\Models\Chat $chat
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(int $lastChatUser)
|
||||
@@ -156,7 +153,7 @@ class ChatController extends Controller
|
||||
'lastChatRecipientUserId' => $lastChatUser->id,
|
||||
'lastChatUsers' => $lastChatUsers,
|
||||
'curUserId' => $curUserId,
|
||||
'chanId' => $this->makeChanName($curUserId, $lastChatUser->id)
|
||||
'chanId' => $this->makeChanName($curUserId, $lastChatUser->id),
|
||||
]
|
||||
);
|
||||
//
|
||||
@@ -165,7 +162,6 @@ class ChatController extends Controller
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\chat $chat
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(chat $chat)
|
||||
@@ -176,8 +172,6 @@ class ChatController extends Controller
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\chat $chat
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, chat $chat)
|
||||
@@ -188,7 +182,6 @@ class ChatController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\chat $chat
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(chat $chat)
|
||||
|
||||
Reference in New Issue
Block a user