merge ticket928
This commit is contained in:
commit
b0081e82e6
5 changed files with 45 additions and 16 deletions
|
|
@ -34,22 +34,16 @@ class AccountController extends Controller
|
|||
*
|
||||
* @param Builder $query
|
||||
* @return Builder
|
||||
* @throws \ErrorException If account is missing in url.
|
||||
*/
|
||||
public function indexQuery(Builder $query): Builder
|
||||
{
|
||||
/** @var \App\Models\User */
|
||||
$user = auth()->user();
|
||||
if (!$user->isAdmin()) {
|
||||
// Show only users brand(s) accounts.
|
||||
$brands = $user->sites()->with('brand')->get()->pluck('brand')
|
||||
->filter(function ($v) {
|
||||
return !\is_null($v);
|
||||
});
|
||||
return $query->whereHas('brand', function ($q) use ($brands) {
|
||||
$q->whereIn('id', $brands->pluck('id'));
|
||||
});
|
||||
/** @var \App\Models\Brand|null $brand */
|
||||
if (!($brand = request()->brand)) {
|
||||
throw new \ErrorException('Cannot get brand');
|
||||
}
|
||||
return $query;
|
||||
|
||||
return $query->where('brand_id', '=', $brand->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,11 +30,20 @@ class CreditLogController extends Controller
|
|||
*
|
||||
* @param Builder $query
|
||||
* @return Builder
|
||||
* @throws \ErrorException If account is missing in url.
|
||||
*/
|
||||
public function indexQuery(Builder $query): Builder
|
||||
{
|
||||
$query->orderBy('created_at', 'DESC');
|
||||
return $query;
|
||||
|
||||
/** @var \App\Models\Credit\Account|null $account */
|
||||
if (!($account = request()->account)) {
|
||||
throw new \ErrorException('Cannot get account');
|
||||
}
|
||||
|
||||
return $query->whereHas('account', function ($q) use ($account) {
|
||||
$q->whereIn('id', $account->pluck('id'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
10
composer.lock
generated
10
composer.lock
generated
|
|
@ -1509,12 +1509,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Kwaadpepper/crud-policies.git",
|
||||
"reference": "b9588ab2633493b635aa0aa77013265ed400332d"
|
||||
"reference": "c25ff96be976796a5447bd75d6ef16a0d7226f47"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Kwaadpepper/crud-policies/zipball/b9588ab2633493b635aa0aa77013265ed400332d",
|
||||
"reference": "b9588ab2633493b635aa0aa77013265ed400332d",
|
||||
"url": "https://api.github.com/repos/Kwaadpepper/crud-policies/zipball/c25ff96be976796a5447bd75d6ef16a0d7226f47",
|
||||
"reference": "c25ff96be976796a5447bd75d6ef16a0d7226f47",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1567,7 +1567,11 @@
|
|||
"issues": "https://github.com/Kwaadpepper/crud-policies/issues",
|
||||
"source": "https://github.com/Kwaadpepper/crud-policies/tree/0.4.5"
|
||||
},
|
||||
<<<<<<< HEAD
|
||||
"time": "2022-06-15T15:19:14+00:00"
|
||||
=======
|
||||
"time": "2022-06-15T15:42:22+00:00"
|
||||
>>>>>>> origin/ticket928
|
||||
},
|
||||
{
|
||||
"name": "kwaadpepper/enum",
|
||||
|
|
|
|||
|
|
@ -30,6 +30,14 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-1">
|
||||
<span class="fw-bold h4">{{ __('Marque')}}</span>
|
||||
</div>
|
||||
<div class="col">
|
||||
<b class="h4">{{ optional(request()->brand)->name }}</b>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table text-center">
|
||||
<thead class="thead-dark">
|
||||
@include('crud-policies::crud.modules.sorter')
|
||||
|
|
|
|||
|
|
@ -30,6 +30,14 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-1">
|
||||
<span class="fw-bold h4">{{ __('Compte')}}</span>
|
||||
</div>
|
||||
<div class="col">
|
||||
<b class="h4">{{ optional(request()->account)->label }}</b>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table text-center">
|
||||
<thead class="thead-dark">
|
||||
@include('crud-policies::crud.modules.sorter')
|
||||
|
|
@ -81,6 +89,12 @@
|
|||
@endif
|
||||
@endforeach
|
||||
|
||||
@if($model->estimation->count())
|
||||
<td>
|
||||
<a href="{{ route('ticket.show', ['ticket' => $model->estimation->first()->ticket]) }}">{{ __('Ticket :id', ['id' => $model->estimation->first()->ticket->id]) }}</a>
|
||||
</td>
|
||||
@endif
|
||||
|
||||
{{-- MODEL ACTIONS --}}
|
||||
<td>
|
||||
<div class="btn-group" role="group" aria-label="{{ Str::plural(__('crud-policies::crud.action')) }}">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue