Skip to content

Commit c0e3b33

Browse files
author
Itamar Junior
committed
Add active status checkbox and enhance dropdown functionality in company management
- Added a checkbox for 'Active' status in the company edit form. - Updated the actions dropdown button to toggle visibility using Alpine.js. - Modified the dropdown menu to show/hide based on the button click and added a button to filter active/inactive companies. - Improved styling and accessibility of dropdown elements.
1 parent efe6a06 commit c0e3b33

File tree

9 files changed

+645
-500
lines changed

9 files changed

+645
-500
lines changed

app/Livewire/Company/Company.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Company extends Component
2727
public bool $showCroDefinitionsModal = false;
2828
public array $financialYearEnds = [];
2929
public array $lastAGMs = [];
30+
public $active = true;
3031

3132
public $companyDetailsModal = false;
3233
public ?ModelsCompany $viewingCompany = null;
@@ -77,6 +78,7 @@ public function companies()
7778
{
7879
return Business::find(Auth::user()->currentBusiness->id)->companies()
7980
->with('croDocDefinitions')
81+
->where('active', $this->active)
8082
->when($this->search, function ($query) {
8183
$query->where(function ($q) {
8284
$q->where('name', 'like', '%' . $this->search . '%')
@@ -97,6 +99,11 @@ public function companies()
9799
->paginate($this->perPage);
98100
}
99101

102+
public function showAllCompanies()
103+
{
104+
$this->active = !$this->active;
105+
}
106+
100107
/**
101108
* Sorts the companies by the specified column.
102109
* Toggles the sorting direction between ascending and descending

app/Livewire/Company/CompanyEdit.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class CompanyEdit extends Component
1515
public ?string $custom = null;
1616
public ?string $company_type = null;
1717
public ?string $status = null;
18+
public bool $active = true;
1819
public ?string $effective_date = null;
1920
public ?string $registration_date = null;
2021
public ?string $last_annual_return = null;
@@ -40,6 +41,7 @@ protected function rules(): array
4041
'custom' => 'nullable|string',
4142
'company_type' => 'nullable|string',
4243
'status' => 'nullable|string',
44+
'active' => 'boolean',
4345
'effective_date' => 'nullable|date',
4446
'registration_date' => 'nullable|date',
4547
'last_annual_return' => 'nullable|date',
@@ -72,6 +74,7 @@ public function mount(CompanyModel $company)
7274
'custom',
7375
'company_type',
7476
'status',
77+
'active',
7578
'effective_date',
7679
'registration_date',
7780
'last_annual_return',
@@ -101,6 +104,7 @@ public function save()
101104
'custom' => $this->custom,
102105
'company_type' => $this->company_type,
103106
'status' => $this->status,
107+
'active' => $this->active,
104108
'effective_date' => $this->effective_date,
105109
'registration_date' => $this->registration_date,
106110
'last_annual_return' => $this->last_annual_return,

app/Models/Company.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Company extends Model
2020
'company_number',
2121
'company_type',
2222
'status',
23+
'active',
2324
'effective_date',
2425
'registration_date',
2526
'last_annual_return',
@@ -38,6 +39,18 @@ class Company extends Model
3839
'company_status_code',
3940
];
4041

42+
protected $casts = [
43+
'effective_date' => 'date',
44+
'registration_date' => 'date',
45+
'last_annual_return' => 'date',
46+
'next_annual_return' => 'date',
47+
'next_financial_statement_due' => 'date',
48+
'last_accounts' => 'date',
49+
'last_agm' => 'date',
50+
'financial_year_end' => 'date',
51+
'active' => 'boolean',
52+
];
53+
4154
/**
4255
* Eloquent event hook for when a Company is created.
4356
*

0 commit comments

Comments
 (0)