-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
500 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/Filament/Resources/AccountResource/Pages/AccountDetail.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\AccountResource\Pages; | ||
|
||
use App\Filament\Resources\AccountResource; | ||
use App\Models\Account; | ||
use Carbon\Carbon; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Filament\Resources\Pages\Page; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Filament\Tables; | ||
use Illuminate\Contracts\View\View; | ||
use Webbingbrasil\FilamentDateFilter\DateFilter; | ||
use Filament\Forms; | ||
use Filament\Tables\Filters\Filter; | ||
|
||
class AccountDetail extends Page implements Tables\Contracts\HasTable | ||
{ | ||
use Tables\Concerns\InteractsWithTable; | ||
|
||
protected static string $resource = AccountResource::class; | ||
|
||
protected static string $view = 'filament.resources.account-resource.pages.account-detail'; | ||
|
||
public $record; | ||
|
||
public $account; | ||
|
||
public function mount($record) | ||
{ | ||
$this->record = $record; | ||
$this->account = Account::find($record); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire\Account; | ||
|
||
use Carbon\Carbon; | ||
use Filament\Forms; | ||
use Filament\Tables; | ||
use App\Models\Account; | ||
use App\Models\Expense; | ||
use Livewire\Component; | ||
use Filament\Tables\Filters\Filter; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class ExpenseTable extends Component implements Tables\Contracts\HasTable | ||
{ | ||
use Tables\Concerns\InteractsWithTable; | ||
|
||
public $accountID; | ||
|
||
protected function getTableQuery(): Builder | ||
{ | ||
return Expense::query()->where('account_id', $this->accountID); | ||
} | ||
|
||
protected function getTableColumns(): array | ||
{ | ||
return [ | ||
Tables\Columns\TextColumn::make('due_at') | ||
->label('Date') | ||
->sortable() | ||
->dateTime('d/m/Y'), | ||
Tables\Columns\TextColumn::make('description') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('company.name') | ||
->searchable() | ||
->label('Company'), | ||
Tables\Columns\TextColumn::make('corporation.name') | ||
->searchable() | ||
->label('Corporation'), | ||
Tables\Columns\TextColumn::make('amount_with_currency') | ||
->label('Amount') | ||
->formatStateUsing(fn ($state) => '-' . $state) | ||
->sortable(), | ||
]; | ||
} | ||
|
||
protected function getTableFilters(): array | ||
{ | ||
return [ | ||
Filter::make('due_at') | ||
->form([ | ||
Forms\Components\DatePicker::make('due_from') | ||
->default(Carbon::now()->subYear()) | ||
->closeOnDateSelection() | ||
->timezone('Europe/Istanbul') | ||
->label('From Date'), | ||
Forms\Components\DatePicker::make('due_until') | ||
->closeOnDateSelection() | ||
->timezone('Europe/Istanbul') | ||
->label('To Date') | ||
]) | ||
->query(function (Builder $query, array $data): Builder { | ||
return $query | ||
->when( | ||
$data['due_from'], | ||
fn (Builder $query, $date): Builder => $query->whereDate('due_at', '>=', $date), | ||
) | ||
->when( | ||
$data['due_until'], | ||
fn (Builder $query, $date): Builder => $query->whereDate('due_at', '<=', $date), | ||
); | ||
}), | ||
Filter::make('amount') | ||
->form([ | ||
Forms\Components\TextInput::make('min_amount') | ||
->label('Min Amount'), | ||
Forms\Components\TextInput::make('max_amount') | ||
->label('Max Amount') | ||
]) | ||
->query(function (Builder $query, array $data): Builder { | ||
return $query | ||
->when( | ||
$data['min_amount'], | ||
fn (Builder $query, $amount): Builder => $query->where('amount', '>=', $amount), | ||
) | ||
->when( | ||
$data['max_amount'], | ||
fn (Builder $query, $amount): Builder => $query->where('amount', '<=', $amount), | ||
); | ||
}), | ||
]; | ||
} | ||
|
||
protected function getTableFiltersFormColumns(): int | ||
{ | ||
return 2; | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('livewire.account.expense-table'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire\Account; | ||
|
||
use Carbon\Carbon; | ||
use Filament\Forms; | ||
use Filament\Tables; | ||
use App\Models\Account; | ||
use App\Models\Revenue; | ||
use Livewire\Component; | ||
use Filament\Tables\Filters\Filter; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class RevenueTable extends Component implements Tables\Contracts\HasTable | ||
{ | ||
use Tables\Concerns\InteractsWithTable; | ||
|
||
public $accountID; | ||
|
||
protected function getTableQuery(): Builder | ||
{ | ||
return Revenue::query()->where('account_id', $this->accountID); | ||
} | ||
|
||
protected function getTableColumns(): array | ||
{ | ||
return [ | ||
Tables\Columns\TextColumn::make('due_at') | ||
->label('Date') | ||
->sortable() | ||
->dateTime('d/m/Y'), | ||
Tables\Columns\TextColumn::make('description') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('company.name') | ||
->searchable() | ||
->label('Company'), | ||
Tables\Columns\TextColumn::make('corporation.name') | ||
->searchable() | ||
->label('Corporation'), | ||
Tables\Columns\TextColumn::make('amount_with_currency') | ||
->label('Amount') | ||
->sortable(), | ||
]; | ||
} | ||
|
||
protected function getTableFilters(): array | ||
{ | ||
return [ | ||
Filter::make('due_at') | ||
->form([ | ||
Forms\Components\DatePicker::make('due_from') | ||
->default(Carbon::now()->subYear()) | ||
->closeOnDateSelection() | ||
->timezone('Europe/Istanbul') | ||
->label('From Date'), | ||
Forms\Components\DatePicker::make('due_until') | ||
->closeOnDateSelection() | ||
->timezone('Europe/Istanbul') | ||
->label('To Date') | ||
]) | ||
->query(function (Builder $query, array $data): Builder { | ||
return $query | ||
->when( | ||
$data['due_from'], | ||
fn (Builder $query, $date): Builder => $query->whereDate('due_at', '>=', $date), | ||
) | ||
->when( | ||
$data['due_until'], | ||
fn (Builder $query, $date): Builder => $query->whereDate('due_at', '<=', $date), | ||
); | ||
}), | ||
Filter::make('amount') | ||
->form([ | ||
Forms\Components\TextInput::make('min_amount') | ||
->label('Min Amount'), | ||
Forms\Components\TextInput::make('max_amount') | ||
->label('Max Amount') | ||
]) | ||
->query(function (Builder $query, array $data): Builder { | ||
return $query | ||
->when( | ||
$data['min_amount'], | ||
fn (Builder $query, $amount): Builder => $query->where('amount', '>=', $amount), | ||
) | ||
->when( | ||
$data['max_amount'], | ||
fn (Builder $query, $amount): Builder => $query->where('amount', '<=', $amount), | ||
); | ||
}), | ||
]; | ||
} | ||
|
||
protected function getTableFiltersFormColumns(): int | ||
{ | ||
return 2; | ||
} | ||
|
||
public function render(): View | ||
{ | ||
return view('livewire.account.revenue-table'); | ||
} | ||
} |
Oops, something went wrong.