forked from eatvio/eatvio-infra
static analizys update
This commit is contained in:
@@ -3,61 +3,15 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Events\ChatMessageUpdated;
|
||||
use App\Messages\ChatMessage;
|
||||
use App\Models\Chat;
|
||||
use App\Models\User;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ChatMessage
|
||||
{
|
||||
public $id;
|
||||
|
||||
public $payload;
|
||||
|
||||
public function __construct($id, $payload)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->payload = $payload;
|
||||
}
|
||||
|
||||
public function someRandomFillFunction()
|
||||
{
|
||||
$users1 = User::all()->pluck('id');
|
||||
$users2 = User::all()->pluck('id');
|
||||
$faker = Faker\Factory::create();
|
||||
|
||||
$users1->each(
|
||||
function ($user1, $key) use ($faker, $users2) {
|
||||
$users2->each(
|
||||
function ($user2) use ($faker, $user1) {
|
||||
if ($user1 === $user2) {
|
||||
return;
|
||||
}
|
||||
$data1 = [
|
||||
'from_user_id' => $user2,
|
||||
'to_user_id' => $user1,
|
||||
'data' => $faker->text(),
|
||||
];
|
||||
|
||||
$data2 = [
|
||||
'from_user_id' => $user1,
|
||||
'to_user_id' => $user2,
|
||||
'data' => $faker->text(),
|
||||
];
|
||||
|
||||
$newMessage = (new Chat())->forceFill($data1);
|
||||
$newMessage->save();
|
||||
$newMessage = (new Chat())->forceFill($data2);
|
||||
$newMessage->save();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class ChatController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
public function index(): View|ViewFactory
|
||||
{
|
||||
// $_ = "from_user_id to_user_id";
|
||||
$curUserId = Auth()->user()->id;
|
||||
@@ -91,17 +45,19 @@ class ChatController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
/*
|
||||
* public function create(): void
|
||||
{
|
||||
ChatMessageUpdated::dispatch(new ChatMessage(time(), 'some text '.md5(time())));
|
||||
ChatMessageUpdated::dispatch(
|
||||
new ChatMessage(
|
||||
time(),
|
||||
'some text '.md5(' '.time())
|
||||
)
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
public function show(int $lastChatUser): View
|
||||
public function show(int $lastChatUser): View|ViewFactory
|
||||
{
|
||||
$lastChatUser = User::find($lastChatUser);
|
||||
// $_ = "from_user_id to_user_id";
|
||||
@@ -129,7 +85,7 @@ class ChatController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
private function makeChanName($from, $to)
|
||||
private function makeChanName(int $from, int $to): string
|
||||
{
|
||||
return (int) $from < (int) $to
|
||||
? $from.'_'.$to
|
||||
|
||||
Reference in New Issue
Block a user