Made 'viewable' scope default behavior

This commit is contained in:
Hillel Coren 2016-07-04 19:49:01 +03:00
parent c339c66623
commit 0dc9b3fceb
6 changed files with 6 additions and 16 deletions

View File

@ -62,7 +62,7 @@ class CreditController extends BaseController
'method' => 'POST',
'url' => 'credits',
'title' => trans('texts.new_credit'),
'clients' => Client::scope()->viewable()->with('contacts')->orderBy('name')->get(),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
];
return View::make('credits.edit', $data);

View File

@ -94,7 +94,6 @@ class PaymentController extends BaseController
public function create(PaymentRequest $request)
{
$invoices = Invoice::scope()
->viewable()
->invoiceType(INVOICE_TYPE_STANDARD)
->where('is_recurring', '=', false)
->where('invoices.balance', '>', 0)
@ -111,7 +110,7 @@ class PaymentController extends BaseController
'url' => 'payments',
'title' => trans('texts.new_payment'),
'paymentTypeId' => Input::get('paymentTypeId'),
'clients' => Client::scope()->viewable()->with('contacts')->orderBy('name')->get(), ];
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), ];
return View::make('payments.edit', $data);
}

View File

@ -123,7 +123,7 @@ class QuoteController extends BaseController
'taxRateOptions' => $options,
'defaultTax' => $defaultTax,
'countries' => Cache::get('countries'),
'clients' => Client::scope()->viewable()->with('contacts', 'country')->orderBy('name')->get(),
'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(),
'taxRates' => TaxRate::scope()->orderBy('name')->get(),
'currencies' => Cache::get('currencies'),
'sizes' => Cache::get('sizes'),

View File

@ -213,7 +213,7 @@ class TaskController extends BaseController
private static function getViewModel()
{
return [
'clients' => Client::scope()->viewable()->with('contacts')->orderBy('name')->get(),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
'account' => Auth::user()->account,
];
}
@ -302,7 +302,7 @@ class TaskController extends BaseController
}
}
}
private function checkTimezone()
{
if (!Auth::user()->account->timezone) {

View File

@ -121,15 +121,6 @@ class EntityModel extends Eloquent
}
}
return $query;
}
/**
* @param $query
* @return mixed
*/
public function scopeViewable($query)
{
if (Auth::check() && ! Auth::user()->hasPermission('view_all')) {
$query->where($this->getEntityType(). 's.user_id', '=', Auth::user()->id);
}

View File

@ -77,7 +77,7 @@ class UserTableSeeder extends Seeder
'account_id' => $account->id,
'client_id' => $client->id,
'public_id' => 1,
'email' => TEST_USERNAME,
'email' => env('TEST_EMAIL', TEST_USERNAME),
'is_primary' => true,
]);