don't load disabled company #369
This commit is contained in:
parent
aeef73ec65
commit
e288a42da0
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Http\ViewComposers;
|
namespace App\Http\ViewComposers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use anlutro\LaravelSettings\Facade as Settingg;
|
use anlutro\LaravelSettings\Facade as Settingg;
|
||||||
|
|
||||||
@ -17,17 +16,16 @@ class Menu
|
|||||||
public function compose(View $view)
|
public function compose(View $view)
|
||||||
{
|
{
|
||||||
$customer = null;
|
$customer = null;
|
||||||
$company_id = session('company_id');
|
$user = auth()->user();
|
||||||
|
|
||||||
// Get all companies
|
// Get all companies
|
||||||
$companies = Auth::user()->companies()->limit(10)->get()->sortBy('name');
|
$companies = $user->companies()->enabled()->limit(10)->get()->each(function ($com) {
|
||||||
foreach ($companies as $com) {
|
|
||||||
$com->setSettings();
|
$com->setSettings();
|
||||||
}
|
})->sortBy('name');
|
||||||
|
|
||||||
// Get customer
|
// Get customer
|
||||||
if (Auth::user()->customer) {
|
if ($user->customer) {
|
||||||
$customer = Auth::user();
|
$customer = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
$view->with(['companies' => $companies, 'customer' => $customer]);
|
$view->with(['companies' => $companies, 'customer' => $customer]);
|
||||||
|
@ -17,7 +17,7 @@ class Login
|
|||||||
public function handle(ILogin $event)
|
public function handle(ILogin $event)
|
||||||
{
|
{
|
||||||
// Get first company
|
// Get first company
|
||||||
$company = $event->user->companies()->first();
|
$company = $event->user->companies()->enabled()->first();
|
||||||
|
|
||||||
// Logout if no company assigned
|
// Logout if no company assigned
|
||||||
if (!$company) {
|
if (!$company) {
|
||||||
|
@ -204,6 +204,18 @@ class Company extends Eloquent
|
|||||||
return Auth::user()->companies()->filter($input)->sortable($sort)->paginate($limit);
|
return Auth::user()->companies()->filter($input)->sortable($sort)->paginate($limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope to only include companies of a given enabled value.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param mixed $value
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeEnabled($query, $value = 1)
|
||||||
|
{
|
||||||
|
return $query->where('enabled', $value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort by company name
|
* Sort by company name
|
||||||
*
|
*
|
||||||
|
@ -62,7 +62,9 @@
|
|||||||
<i class="fa fa-ellipsis-h"></i>
|
<i class="fa fa-ellipsis-h"></i>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu dropdown-menu-right">
|
<ul class="dropdown-menu dropdown-menu-right">
|
||||||
|
@if ($item->enabled)
|
||||||
<li><a href="{{ url('companies/companies/' . $item->id . '/set') }}">{{ trans('general.switch') }}</a></li>
|
<li><a href="{{ url('companies/companies/' . $item->id . '/set') }}">{{ trans('general.switch') }}</a></li>
|
||||||
|
@endif
|
||||||
<li><a href="{{ url('companies/companies/' . $item->id . '/edit') }}">{{ trans('general.edit') }}</a></li>
|
<li><a href="{{ url('companies/companies/' . $item->id . '/edit') }}">{{ trans('general.edit') }}</a></li>
|
||||||
@permission('delete-companies-companies')
|
@permission('delete-companies-companies')
|
||||||
<li>{!! Form::deleteLink($item, 'companies/companies', '', 'company_name') !!}</li>
|
<li>{!! Form::deleteLink($item, 'companies/companies', '', 'company_name') !!}</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user