mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 09:14:08 +00:00
Add return types and typed parameters to remaining 10 models
Complete the type modernization across all models. Adds Builder-typed $query parameters and return types to all scope methods, typed parameters on accessors, and PHPDoc on scopePaginateData/scopeApplyFilters. Models updated: Address, EstimateItem, Expense, ExpenseCategory, InvoiceItem, Item, Note, Tax, TaxType, Unit. 5 models needed no changes (Country, Currency, ImpersonationLog, Module, UserSetting) as they had no untyped public methods.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -17,7 +18,7 @@ class Note extends Model
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function scopeApplyFilters($query, array $filters)
|
||||
public function scopeApplyFilters(Builder $query, array $filters): void
|
||||
{
|
||||
$filters = collect($filters);
|
||||
|
||||
@@ -30,17 +31,17 @@ class Note extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function scopeWhereSearch($query, $search)
|
||||
public function scopeWhereSearch(Builder $query, string $search): void
|
||||
{
|
||||
$query->where('name', 'LIKE', '%'.$search.'%');
|
||||
}
|
||||
|
||||
public function scopeWhereType($query, $type)
|
||||
public function scopeWhereType(Builder $query, string $type): Builder
|
||||
{
|
||||
return $query->where('type', $type);
|
||||
}
|
||||
|
||||
public function scopeWhereCompany($query)
|
||||
public function scopeWhereCompany(Builder $query): void
|
||||
{
|
||||
$query->where('notes.company_id', request()->header('company'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user