limit search records

This commit is contained in:
Denis Duliçi 2021-02-24 19:31:28 +03:00
parent e666eb88dd
commit eb093c4ef8

View File

@ -26,7 +26,7 @@ class Search extends Controller
$search->keyword = request('keyword'); $search->keyword = request('keyword');
if ($user->can('read-banking-accounts')) { if ($user->can('read-banking-accounts')) {
$accounts = Account::enabled()->usingSearchString($search->keyword)->get(); $accounts = Account::enabled()->usingSearchString($search->keyword)->take(setting('default.select_limit'))->get();
if ($accounts->count()) { if ($accounts->count()) {
foreach ($accounts as $account) { foreach ($accounts as $account) {
@ -42,7 +42,7 @@ class Search extends Controller
} }
if ($user->can('read-common-items')) { if ($user->can('read-common-items')) {
$items = Item::enabled()->usingSearchString($search->keyword)->get(); $items = Item::enabled()->usingSearchString($search->keyword)->take(setting('default.select_limit'))->get();
if ($items->count()) { if ($items->count()) {
foreach ($items as $item) { foreach ($items as $item) {
@ -58,7 +58,7 @@ class Search extends Controller
} }
if ($user->can('read-sales-invoices')) { if ($user->can('read-sales-invoices')) {
$invoices = Document::invoice()->usingSearchString($search->keyword)->get(); $invoices = Document::invoice()->usingSearchString($search->keyword)->take(setting('default.select_limit'))->get();
if ($invoices->count()) { if ($invoices->count()) {
foreach ($invoices as $invoice) { foreach ($invoices as $invoice) {
@ -74,7 +74,7 @@ class Search extends Controller
} }
/*if ($user->can('read-sales-revenues')) { /*if ($user->can('read-sales-revenues')) {
$revenues = Transaction::income()->usingSearchString($search->keyword)->get(); $revenues = Transaction::income()->usingSearchString($search->keyword)->take(setting('default.select_limit'))->get();
if ($revenues->count()) { if ($revenues->count()) {
foreach ($revenues as $revenue) { foreach ($revenues as $revenue) {
@ -90,7 +90,7 @@ class Search extends Controller
}*/ }*/
if ($user->can('read-sales-customers')) { if ($user->can('read-sales-customers')) {
$customers = Contact::customer()->enabled()->usingSearchString($search->keyword)->get(); $customers = Contact::customer()->enabled()->usingSearchString($search->keyword)->take(setting('default.select_limit'))->get();
if ($customers->count()) { if ($customers->count()) {
foreach ($customers as $customer) { foreach ($customers as $customer) {
@ -106,7 +106,7 @@ class Search extends Controller
} }
if ($user->can('read-purchases-bills')) { if ($user->can('read-purchases-bills')) {
$bills = Document::bill()->usingSearchString($search->keyword)->get(); $bills = Document::bill()->usingSearchString($search->keyword)->take(setting('default.select_limit'))->get();
if ($bills->count()) { if ($bills->count()) {
foreach ($bills as $bill) { foreach ($bills as $bill) {
@ -122,7 +122,7 @@ class Search extends Controller
} }
/*if ($user->can('read-purchases-payments')) { /*if ($user->can('read-purchases-payments')) {
$payments = Transaction::expense()->usingSearchString($search->keyword)->get(); $payments = Transaction::expense()->usingSearchString($search->keyword)->take(setting('default.select_limit'))->get();
if ($payments->count()) { if ($payments->count()) {
foreach ($payments as $payment) { foreach ($payments as $payment) {
@ -138,7 +138,7 @@ class Search extends Controller
}*/ }*/
if ($user->can('read-purchases-vendors')) { if ($user->can('read-purchases-vendors')) {
$vendors = Contact::vendor()->enabled()->usingSearchString($search->keyword)->get(); $vendors = Contact::vendor()->enabled()->usingSearchString($search->keyword)->take(setting('default.select_limit'))->get();
if ($vendors->count()) { if ($vendors->count()) {
foreach ($vendors as $vendor) { foreach ($vendors as $vendor) {