fixed, eager loading, variable names, clean up
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Models\AssetModel;
|
||||
use App\Models\Category;
|
||||
use App\Models\Checkoutable;
|
||||
use App\Models\Component;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\Maintenance;
|
||||
use App\Models\CheckoutAcceptance;
|
||||
@@ -22,6 +23,7 @@ use App\Models\License;
|
||||
use App\Models\ReportTemplate;
|
||||
use App\Models\Setting;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
@@ -1228,6 +1230,7 @@ class ReportsController extends Controller
|
||||
Accessory::class => ['category','checkouts', 'company'],
|
||||
LicenseSeat::class => ['user', 'license'],
|
||||
Component::class => ['assignedTo', 'company'],
|
||||
Consumable::class => ['company'],
|
||||
]);
|
||||
},
|
||||
'assignedTo',
|
||||
@@ -1247,7 +1250,7 @@ class ReportsController extends Controller
|
||||
trans('admin/companies/table.title'),
|
||||
trans('general.category'),
|
||||
trans('admin/hardware/form.model'),
|
||||
trans('admin/hardware/form.name'),
|
||||
trans('general.name'),
|
||||
trans('admin/hardware/table.asset_tag'),
|
||||
trans('admin/hardware/table.checkoutto'),
|
||||
];
|
||||
@@ -1262,10 +1265,10 @@ class ReportsController extends Controller
|
||||
$row = [ ];
|
||||
$row[] = str_replace(',', '', $item->acceptance->created_at);
|
||||
$row[] = str_replace(',', '', $item->type);
|
||||
$row[] = str_replace(',', '', $item->company_plain);
|
||||
$row[] = str_replace(',', '', $item->category_plain);
|
||||
$row[] = str_replace(',', '', $item->model_plain);
|
||||
$row[] = str_replace(',', '', $item->name_plain);
|
||||
$row[] = str_replace(',', '', $item->plain_text_company);
|
||||
$row[] = str_replace(',', '', $item->plain_text_category);
|
||||
$row[] = str_replace(',', '', $item->plain_text_model);
|
||||
$row[] = str_replace(',', '', $item->plain_text_name);
|
||||
$row[] = str_replace(',', '', $item->asset_tag);
|
||||
$row[] = str_replace(',', '', ($item->acceptance->assignedto) ? $item->acceptance->assignedto->display_name : trans('admin/reports/general.deleted_user'));
|
||||
$rows[] = implode(',', $row);
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
|
||||
|
||||
class Checkoutable
|
||||
{
|
||||
public function __construct(
|
||||
@@ -17,17 +14,12 @@ class Checkoutable
|
||||
public string $type,
|
||||
public object $acceptance,
|
||||
public object $assignee,
|
||||
public readonly string $category_plain,
|
||||
public readonly string $model_plain,
|
||||
public readonly string $name_plain,
|
||||
public readonly string $company_plain,
|
||||
public readonly string $plain_text_category,
|
||||
public readonly string $plain_text_model,
|
||||
public readonly string $plain_text_name,
|
||||
public readonly string $plain_text_company,
|
||||
){}
|
||||
|
||||
// public static function fromCheckoutable(Asset|Accessory|etc..)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
public static function fromAcceptance(CheckoutAcceptance $unaccepted): self
|
||||
{
|
||||
$unaccepted_row = $unaccepted->checkoutable;
|
||||
@@ -55,7 +47,7 @@ class Checkoutable
|
||||
$category = optional($unaccepted_row->license->category?->present())->nameUrl() ?? '';
|
||||
$company = optional($unaccepted_row->license->company?->present())?->nameUrl() ?? '';
|
||||
$model = '';
|
||||
$name = $unaccepted_row->license->name ?? '';
|
||||
$name = $unaccepted_row->license->present()->nameUrl() ?? '';
|
||||
}
|
||||
if($unaccepted_row instanceof Consumable){
|
||||
$category = optional($unaccepted_row->category?->present())->nameUrl() ?? '';
|
||||
@@ -69,7 +61,6 @@ class Checkoutable
|
||||
$name = $unaccepted_row?->present()?->nameUrl() ?? '';
|
||||
|
||||
}
|
||||
$created = $acceptance->created_at;
|
||||
|
||||
return new self(
|
||||
acceptance_id: $acceptance->id,
|
||||
@@ -82,10 +73,10 @@ class Checkoutable
|
||||
acceptance: $acceptance,
|
||||
assignee: $assignee,
|
||||
//plain text for CSVs
|
||||
category_plain: ($unaccepted_row->model?->category?->name ?? $unaccepted_row->license->category?->name ?? $unaccepted_row->category?->name ?? ''),
|
||||
model_plain: ($unaccepted_row->model?->name ?? $unaccepted_row->model_number ?? ''),
|
||||
name_plain: ($unaccepted_row->name ?? $unaccepted_row->license?->name ?? ''),
|
||||
company_plain: ($unaccepted_row->company)->name ?? $unaccepted_row->license->company?->name ?? '',
|
||||
plain_text_category: ($unaccepted_row->model?->category?->name ?? $unaccepted_row->license->category?->name ?? $unaccepted_row->category?->name ?? ''),
|
||||
plain_text_model: ($unaccepted_row->model?->name ?? $unaccepted_row->model_number ?? ''),
|
||||
plain_text_name: ($unaccepted_row->name ?? $unaccepted_row->license?->name ?? ''),
|
||||
plain_text_company: ($unaccepted_row->company)->name ?? $unaccepted_row->license->company?->name ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<th class="col-sm-1" data-sortable="true" >{{ trans('admin/companies/table.title') }}</th>
|
||||
<th class="col-sm-1" data-sortable="true" >{{ trans('general.category') }}</th>
|
||||
<th class="col-sm-1" data-sortable="true" >{{ trans('admin/hardware/form.model') }}</th>
|
||||
<th class="col-sm-1" data-sortable="true" >{{ trans('admin/hardware/form.name') }}</th>
|
||||
<th class="col-sm-1" data-sortable="true" >{{ trans('general.name') }}</th>
|
||||
<th class="col-sm-1" data-sortable="true" >{{ trans('admin/hardware/table.asset_tag') }}</th>
|
||||
<th class="col-sm-1" data-sortable="true" >{{ trans('admin/hardware/table.checkoutto') }}</th>
|
||||
<th class="col-md-1"><span class="line"></span>{{ trans('table.actions') }}</th>
|
||||
@@ -92,8 +92,8 @@
|
||||
</td>
|
||||
|
||||
{{-- Actions: send reminder / delete --}}
|
||||
<td class="white-space: nowrap;">
|
||||
<nobr>
|
||||
<td class="text-nowrap">
|
||||
|
||||
@unless($item->acceptance->trashed())
|
||||
<form method="post" class="white-space: nowrap;" action="{{ route('reports/unaccepted_assets_sent_reminder') }}">
|
||||
@csrf
|
||||
@@ -104,10 +104,10 @@
|
||||
</button>
|
||||
@else
|
||||
<span data-tooltip="true" data-title="{{ trans('admin/reports/general.cannot_send_reminder') }}">
|
||||
<a class="btn btn-sm btn-warning disabled" href="#">
|
||||
<i class="fa fa-repeat" aria-hidden="true"></i>
|
||||
</a>
|
||||
</span>
|
||||
<a class="btn btn-sm btn-warning disabled" href="#">
|
||||
<i class="fa fa-repeat" aria-hidden="true"></i>
|
||||
</a>
|
||||
</span>
|
||||
@endif
|
||||
<a href="{{ route('reports/unaccepted_assets_delete', ['acceptanceId' => $item->acceptance_id]) }}"
|
||||
class="btn btn-sm btn-danger delete-asset"
|
||||
@@ -120,7 +120,6 @@
|
||||
</a>
|
||||
</form>
|
||||
@endunless
|
||||
</nobr>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
Reference in New Issue
Block a user