Skip to content

Commit

Permalink
chore: tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
mahatmamahardhikach committed Nov 12, 2024
1 parent 68556ad commit ed89f22
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 50 deletions.
6 changes: 2 additions & 4 deletions app/Livewire/FormCompanyOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ public function updatedCompanyCode(string $companyCode): void
{
$this->dispatch('set-company', $companyCode);
}

/**
* Handle set company event.
*
* @param string $companyCode
* @return void
*/
#[On('set-company')]
public function setCompany(string $companyCode): void
Expand Down Expand Up @@ -57,4 +55,4 @@ public function render(): View
'companies' => self::getCompanyData(),
]);
}
}
}
2 changes: 1 addition & 1 deletion app/Livewire/ImportUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,4 @@ public function render(): View
{
return view('livewire.import-user');
}
}
}
4 changes: 1 addition & 3 deletions app/Livewire/ImportWorkingCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class ImportWorkingCalendar extends Component

/**
* Called when the import value is updated.
*
* @return void
*/
public function updatedImport(): void
{
Expand Down Expand Up @@ -103,4 +101,4 @@ public function render(): View
{
return view('livewire.import-working-calendar');
}
}
}
2 changes: 1 addition & 1 deletion app/Livewire/PageFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ public function render(): View
'companies' => Company::all(),
]);
}
}
}
28 changes: 3 additions & 25 deletions app/Livewire/ProfileCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Livewire\Attributes\Url;
use Livewire\Component;


class ProfileCard extends Component
{
#[Url(keep: true)]
Expand Down Expand Up @@ -51,15 +50,13 @@ public function mount(): void
$this->user = $this->userDetail->user;
}

if (!$this->user) {
if (! $this->user) {
$this->user = auth()->user();
}
}

/**
* Set the company code
*
* @param string $companyCode
*/
#[On('set-company')]
public function setCompany(string $companyCode): void
Expand All @@ -69,8 +66,6 @@ public function setCompany(string $companyCode): void

/**
* Set the branch code
*
* @param string $branchCode
*/
#[On('set-branch')]
public function setBranch(string $branchCode): void
Expand All @@ -80,57 +75,42 @@ public function setBranch(string $branchCode): void

/**
* Set the department code
*
* @param string $departmentCode
*/
#[On('set-department')]
public function setDepartment(string $departmentCode): void
{
$this->departmentCode = $departmentCode;
}


/**
* Set the division code
*
* @param string $divisionCode
*/
#[On('set-division')]
public function setDivision(string $divisionCode): void
{
$this->divisionCode = $divisionCode;
}


/**
* Set the subdivision code
*
* @param string $subDivisionCode
*/
#[On('set-sub-division')]
public function setSubDivision(string $subDivisionCode): void
{
$this->subDivisionCode = $subDivisionCode;
}


/**
* Set the level code
*
* @param string $levelCode
*/
#[On('set-level')]
public function setLevel(string $levelCode): void
{
$this->levelCode = $levelCode;
}



/**
* Set the position code
*
* @param string $positionCode
*/
#[On('set-position')]
public function setPosition(string $positionCode): void
Expand All @@ -140,13 +120,11 @@ public function setPosition(string $positionCode): void

/**
* Render the profile card view
*
* @return View
*/
public function render(): View
{
return view('livewire.profile-card', [
'user' => $this->user
'user' => $this->user,
]);
}
}
}
2 changes: 1 addition & 1 deletion app/Livewire/RegisterCompanyPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ public function render(): View
{
return view('livewire.register-company-page');
}
}
}
11 changes: 2 additions & 9 deletions app/Livewire/UserDetailForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use App\Models\Level;
use App\Models\Position;
use App\Models\SubDivision;
use App\Models\User;
use App\Models\UserDetail;
use Illuminate\Contracts\View\View;
use Livewire\Attributes\On;
Expand Down Expand Up @@ -103,14 +102,11 @@ class UserDetailForm extends Component

public function mount(): void
{
if($this->nik != '') {
if ($this->nik != '') {
$this->setUser();
}
}

/**
* @return void
*/
public function setUser(): void
{
$this->userDetail = UserDetail::where('nik', $this->nik)->first();
Expand All @@ -126,9 +122,6 @@ public function setDetail($details): void
}

#[On('set-company')]
/**
* @param string $companyCode
*/
public function setCompany(string $companyCode): void
{
$this->details['company_code'] = $companyCode;
Expand Down Expand Up @@ -199,4 +192,4 @@ public function render(): View
{
return view('livewire.user-detail-form');
}
}
}
10 changes: 4 additions & 6 deletions app/Livewire/UserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class UserForm extends Component
public $userDetail;

public $actionForm = 'save';

public $cancelButton = true;

/**
Expand All @@ -112,7 +113,7 @@ public function mount(): void
$this->setBranch($this->branchCode);
}

if($this->user){
if ($this->user) {
$this->setUser();
}
}
Expand Down Expand Up @@ -232,14 +233,11 @@ public function setPosition(string $positionCode): void
}
}

/**
* @return void
*/
public function setUser(): void
{
$this->userDetail = UserDetail::where('user_id', $this->user->id)->first();
$this->setDetail($this->userDetail->toArray());

$this->name = $this->user->name;
$this->email = $this->user->email;
$this->companyCode = $this->userDetail->company_code ?? '';
Expand Down Expand Up @@ -471,4 +469,4 @@ public function render(): View
{
return view('livewire.user-form');
}
}
}

0 comments on commit ed89f22

Please sign in to comment.