forked from eatvio/eatvio-infra
refactor code registration for static analyse
This commit is contained in:
@@ -8,8 +8,10 @@ use App\Models\UserAttachment;
|
||||
use App\Notifications\ConsultantRequestStarted;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class RegistrationForm extends Component
|
||||
{
|
||||
@@ -27,15 +29,15 @@ class RegistrationForm extends Component
|
||||
|
||||
public string $telegramLink = '';
|
||||
|
||||
public bool $hasMedicalEducation = false;
|
||||
public bool|int $hasMedicalEducation = false;
|
||||
|
||||
public $certPhotos = [];
|
||||
public array|Collection $certPhotos = [];
|
||||
|
||||
public $tmpCertPhotos = [];
|
||||
public array $tmpCertPhotos = [];
|
||||
|
||||
public string $legalType = 'selfemployed';
|
||||
|
||||
protected $rules = [
|
||||
protected array $rules = [
|
||||
'medicalEducations.*.title' => 'required|string|min:6',
|
||||
'medicalEducations.*.date' => 'required|date',
|
||||
'vkLink' => 'required|url',
|
||||
@@ -46,7 +48,7 @@ class RegistrationForm extends Component
|
||||
'tmpCertPhotos.*' => 'image|max:4024',
|
||||
];
|
||||
|
||||
public function mount()
|
||||
public function mount(): void
|
||||
{
|
||||
$this->user = Auth::user();
|
||||
$consultant_request = $this->user->consultant_request;
|
||||
@@ -61,17 +63,17 @@ class RegistrationForm extends Component
|
||||
|
||||
$photos = $this->user->attachments()->certs()->get();
|
||||
|
||||
if ($photos) {
|
||||
$this->certPhotos = collect($photos);
|
||||
}
|
||||
// if ($photos) {
|
||||
$this->certPhotos = collect($photos);
|
||||
// }
|
||||
}
|
||||
|
||||
public function render()
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.consultant.registration-form');
|
||||
}
|
||||
|
||||
public function addEducation()
|
||||
public function addEducation(): void
|
||||
{
|
||||
$this->validate();
|
||||
$medicalEducations = $this->medicalEducations;
|
||||
@@ -91,7 +93,7 @@ class RegistrationForm extends Component
|
||||
$this->medicalEducations = $medicalEducations;
|
||||
}
|
||||
|
||||
public function remove($index)
|
||||
public function remove(string $index): void
|
||||
{
|
||||
$filteredEducations = array_filter(
|
||||
$this->medicalEducations,
|
||||
@@ -104,7 +106,7 @@ class RegistrationForm extends Component
|
||||
$this->medicalEducations = array_values($filteredEducations);
|
||||
}
|
||||
|
||||
public function save()
|
||||
public function save(): void
|
||||
{
|
||||
$data = [
|
||||
'user_id' => $this->user->id,
|
||||
@@ -131,7 +133,7 @@ class RegistrationForm extends Component
|
||||
$attachmentGroup = 'user_certs';
|
||||
|
||||
foreach ($this->tmpCertPhotos as $photo) {
|
||||
$curCert = $photo->storePublicly('public/'.$attachmentGroup.'/'.$this->user->id);
|
||||
$curCert = $photo->storePublicly('public/' . $attachmentGroup . '/' . $this->user->id);
|
||||
$fileData = [
|
||||
'user_id' => $this->user->id,
|
||||
'group' => $attachmentGroup,
|
||||
@@ -142,7 +144,7 @@ class RegistrationForm extends Component
|
||||
$newFile = UserAttachment::updateOrCreate(
|
||||
$fileData,
|
||||
[
|
||||
'path' => preg_replace("/public\//xi", '/storage/', $curCert),
|
||||
'path' => preg_replace('/public\//xi', '/storage/', $curCert),
|
||||
'specs' => json_encode(
|
||||
[
|
||||
'ext' => $photo->extension(),
|
||||
@@ -158,7 +160,7 @@ class RegistrationForm extends Component
|
||||
$this->user->notify(new ConsultantRequestStarted($consultantEducation));
|
||||
}
|
||||
|
||||
public function deleteImg($id)
|
||||
public function deleteImg(int $id): void
|
||||
{
|
||||
$file = UserAttachment::find($id);
|
||||
$fileSpecs = json_decode($file->specs, true);
|
||||
|
||||
Reference in New Issue
Block a user