{{-- Row actions for the Customer Document Types DataTable — docs/wireframes-v12/customer-doc-type.html (~line 191). Identical in shape to booking_types/partials/actions.blade.php, which carries the long form of why the payload is one escaped JSON attribute, why the delete is a POST form with a Js::from() confirm rather than a link, and why every control is gated on its own ability. Read that file first. The one difference is the payload's fourth key: booking_type_ids the ids of the booking types this document applies to, so the Edit dialog can tick the right boxes without a round trip. Ids and not names: the checkbox values are ids, the association is by id, and a name in a payload is a name that can go stale between the draw and the click. The ids are read from the relation the DataTable already eager-loaded, so this partial adds no query per row — the N+1 pin in the module's DataTable test is what stops that changing quietly. Rendered through rawColumns(['actions']): unescaped output, and every dynamic value in it is either inside the `{{ }}`-escaped `data-row` attribute or inside Js::from(). yajra hands the row's model in as $model. --}} @php /** @var \App\Models\CustomerDocType $model */ $row = [ 'id' => $model->getKey(), 'name' => $model->name, 'url' => route('customer_doc_types.update', $model), 'booking_type_ids' => $model->bookingTypes->pluck('id')->all(), ]; // JSON_INVALID_UTF8_SUBSTITUTE with JSON_THROW_ON_ERROR behind it — the // twin's docblock carries the reasoning in full. The short version: without // it, one invalid UTF-8 byte in one name makes json_encode return `false`, // Blade writes `data-row=""`, JSON.parse rejects it and the pencil is // silently dead. Substituting keeps the failure visible and local to the // row; throwing is kept for the encoding faults that are not about bytes, // where a 500 naming the fault beats a dead button. $rowJson = json_encode($row, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_INVALID_UTF8_SUBSTITUTE | JSON_THROW_ON_ERROR); @endphp
@can('update', $model) @endcan @can('delete', $model) {{-- CR-16 item J2: a plain button, not a form with a confirm(). `data-url` is the destroy route rendered by route() — the client's own instruction — and `data-confirm` is the SAME lang sentence the confirm() showed, which the shared dialog writes with textContent. The masters' own `.btn-icon-sm` is kept: each partial keeps its own wrapper and icon classes. --}} @endcan