Updates for Design Filters

This commit is contained in:
David Bomba 2023-04-19 08:20:46 +10:00
parent 50eceaf9d1
commit 8a0c802ed1
5 changed files with 25 additions and 17 deletions

View File

@ -24,7 +24,6 @@ class DesignFilters extends QueryFilters
* @param string $filter
* @return Builder
*
* @deprecated
*/
public function filter(string $filter = ''): Builder
{
@ -33,7 +32,7 @@ class DesignFilters extends QueryFilters
}
return $this->builder->where(function ($query) use ($filter) {
$query->where('designs.name', 'like', '%'.$filter.'%');
$query->where('name', 'like', '%'.$filter.'%');
});
}
@ -58,17 +57,22 @@ class DesignFilters extends QueryFilters
/**
* Filters the query by the users company ID.
*
* @return Illuminate\Database\Eloquent\Builder
* @return Builder
*/
public function entityFilter(): Builder
{
return $this->builder->where('company_id', auth()->user()->company()->id)->orWhere('company_id', null)->orderBy('id', 'asc');
//19-03-2023 change the scope for the design filters
return $this->builder->where(function ($query) {
$query->where('company_id', auth()->user()->company()->id)->orWhere('company_id', null)->orderBy('id', 'asc');
// return $this->builder->where('company_id', auth()->user()->company()->id)->orWhere('company_id', null)->orderBy('id', 'asc');
});
}
/**
* Filter the designs by `is_custom` column.
*
* @return Illuminate\Database\Eloquent\Builder
* @return Builder
*/
public function custom(string $custom): Builder
{

View File

@ -35,7 +35,7 @@ class InvoiceFilters extends QueryFilters
* - overdue
* - reversed
*
* @param string client_status The invoice status as seen by the client
* @param string $value The invoice status as seen by the client
* @return Builder
*/
public function client_status(string $value = ''): Builder
@ -88,7 +88,7 @@ class InvoiceFilters extends QueryFilters
/**
* Filter based on search text.
*
* @param string query filter
* @param string $filter
* @return Builder
* @deprecated
*/
@ -126,6 +126,7 @@ class InvoiceFilters extends QueryFilters
}
/**
* @return Builder
* @return Builder
* @throws InvalidArgumentException
*/
@ -141,6 +142,7 @@ class InvoiceFilters extends QueryFilters
/**
* @return void
* @return Builder
* @throws InvalidArgumentException
*/
public function overdue(): Builder
@ -174,7 +176,7 @@ class InvoiceFilters extends QueryFilters
/**
* Sorts the list based on $sort.
*
* @param string sort formatted as column|asc
* @param string $sort formatted as column|asc
* @return Builder
*/
public function sort(string $sort = ''): Builder
@ -194,9 +196,9 @@ class InvoiceFilters extends QueryFilters
* We need to ensure we are using the correct company ID
* as we could be hitting this from either the client or company auth guard
*
* @return Illuminate\Database\Query\Builder
* @return Builder
*/
public function entityFilter()
public function entityFilter(): Builder
{
if (auth()->guard('contact')->user()) {
return $this->contactViewFilter();

View File

@ -23,7 +23,7 @@ class ProductFilters extends QueryFilters
/**
* Filter based on search text.
*
* @param string query filter
* @param string $filter
* @return Builder
* @deprecated
*/

View File

@ -115,7 +115,7 @@ abstract class QueryFilters
* Explodes the value by delimiter.
*
* @param string $value
* @return stdClass
* @return \stdClass
*/
public function split($value) : \stdClass
{
@ -133,7 +133,7 @@ abstract class QueryFilters
* Filters the list based on the status
* archived, active, deleted.
*
* @param string filter
* @param string $filter
* @return Builder
*/
public function status(string $filter = ''): Builder
@ -196,13 +196,15 @@ abstract class QueryFilters
*
* -Can only be used on contact routes
*
* @return
* @return Builder
*/
public function clientFilter()
public function clientFilter(): Builder
{
if (auth()->guard('contact')->user()) {
return $this->builder->where('client_id', auth()->guard('contact')->user()->client->id);
}
return $this->builder;
}
public function created_at($value = '')

View File

@ -63,7 +63,7 @@ class PdfMock
$pdf_config->entity_design_id = $pdf_config->settings->{"{$pdf_config->entity_string}_design_id"};
$pdf_config->setPdfVariables();
$pdf_config->setCurrency(Currency::find($this->settings->currency_id));
$pdf_config->setCountry(Country::find($this->settings->country_id));
$pdf_config->setCountry(Country::find($this->settings->country_id ?: 840));
$pdf_config->design = Design::find($this->decodePrimaryKey($pdf_config->entity_design_id));
$pdf_config->currency_entity = $this->mock->client;