fixed #16
This commit is contained in:
parent
173f375a27
commit
d4320ab386
@ -16,7 +16,6 @@ class Companies extends ModelFilter
|
||||
|
||||
public function search($query)
|
||||
{
|
||||
$this->related('settings','settings.key', '=',"'company_name'");
|
||||
return $this->related('settings','settings.value', 'LIKE',"'%" . $query . "%'");
|
||||
return $this->whereLike('value', $query);
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ class Companies extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$companies = Auth::user()->companies()->get()->sortBy('name');
|
||||
$companies = Auth::user()->companies()->collect();
|
||||
|
||||
foreach ($companies as $company) {
|
||||
$company->setSettings();
|
||||
|
@ -22,7 +22,7 @@ class Company extends Eloquent
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $sortable = ['domain'];
|
||||
public $sortable = ['name', 'domain', 'email'];
|
||||
|
||||
public function accounts()
|
||||
{
|
||||
@ -196,4 +196,36 @@ class Company extends Eloquent
|
||||
|
||||
return $this->filter($input)->sortable($sort)->paginate($limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by company name
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $direction
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function nameSortable($query, $direction)
|
||||
{
|
||||
return $query->join('settings', 'companies.id', '=', 'settings.company_id')
|
||||
->where('key', 'general.company_name')
|
||||
->orderBy('value', $direction)
|
||||
->select('companies.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by company email
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param $direction
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function emailSortable($query, $direction)
|
||||
{
|
||||
return $query->join('settings', 'companies.id', '=', 'settings.company_id')
|
||||
->where('key', 'general.company_email')
|
||||
->orderBy('value', $direction)
|
||||
->select('companies.*');
|
||||
}
|
||||
}
|
||||
|
@ -32,11 +32,10 @@
|
||||
<table class="table table-bordered table-striped table-hover" id="tbl-companies">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@sortablelink('company_name', trans('general.name'))</th>
|
||||
<th>@sortablelink('domain', trans('companies.domain'))</th>
|
||||
<th>@sortablelink('company_email', trans('general.email'))</th>
|
||||
|
||||
<th style="width: 15%;">{{ trans('general.actions') }}</th>
|
||||
<th class="col-md-5">@sortablelink('name', trans('general.name'))</th>
|
||||
<th class="col-md-2">@sortablelink('domain', trans('companies.domain'))</th>
|
||||
<th class="col-md-2">@sortablelink('email', trans('general.email'))</th>
|
||||
<th class="col-md-3">{{ trans('general.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -46,6 +45,7 @@
|
||||
<td>{{ $item->domain }}</td>
|
||||
<td>{{ $item->company_email }}</td>
|
||||
<td>
|
||||
<a href="{{ url('companies/companies/' . $item->id . '/set') }}" class="btn btn-info btn-xs"><i class="fa fa-arrow-right" aria-hidden="true"></i> {{ trans('general.change') }}</a>
|
||||
<a href="{{ url('companies/companies/' . $item->id . '/edit') }}" class="btn btn-primary btn-xs"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> {{ trans('general.edit') }}</a>
|
||||
@permission('delete-companies-companies')
|
||||
{!! Form::deleteButton($item, 'companies/companies', '', 'company_name') !!}
|
||||
@ -58,6 +58,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
|
||||
<div class="box-footer">
|
||||
@include('partials.admin.pagination', ['items' => $companies, 'type' => 'companies'])
|
||||
</div>
|
||||
<!-- /.box-footer -->
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
@endsection
|
||||
|
Loading…
x
Reference in New Issue
Block a user