@php // THIS IS A CONST NAME AND MUST TO CORRESPONDE TO THE REFS SECTION if(!isset($id)) $id = 'mediaManager'; # LIST COMPONENTS $id_form = "{$id}Insert"; $id_table = "{$id}Records"; $imgs = []; $product_id = 0; $allow_delete = false; if( !empty($product) ){ // IT SOULD CONTAIN BOTH REQUIRED ID & PRODUCTS $product_id = $product['id']; $through = "{$product_id}/images"; $imgs = $images; $allow_delete = $product->deletable_images; } $headers = [ [ 'label' => __('table.header.id'), 'target' => 'id', ], [ 'label' => __('table.header.name'), 'target' => 'name', ], [ 'label' => __('table.header.type'), 'target' => 'type', 'dclass' => 'lefted', ], [ 'label' => __('table.header.size'), 'target' => 'size.readable', ], [ 'label' => __('table.header.url'), 'target' => 'url', ], [ 'label' => __('table.header.uploaded'), 'target' => 'uploaded', ], ]; if($allow_delete){ // ORDER PRODUCTS DELETABLE array_push($headers, [ 'label' => __('table.header.delete'), 'target' => '_delete' ]); } // GET HEADERS TARGETS $col = array_flip( array_column($headers, 'target') ); @endphp @include('components.tabs', [ 'active' => 'pictures', 'tabs' => [ 'pictures' => [ 'title' => __('label.pictures'), 'layout' => [ 'target' => 'components.table', 'data' => [ 'id' => $id_table, // INPUT ID BIND 'class' => 'table cell-border hover order-images', 'resource' => 'products', // FORM RESOURCE TARGET 'method' => config('const.crud.delete'), // RESOURCE METHOD AVAILABLE 'through' => $through, // THROUGH SPEC 'rows_id' => "pivot.id", // ROWS ID FIELD SPEC (DEFAULT ID) 'data' => $imgs, // PASS DATA IF ANY 'headers' => $headers ], ] ], 'upload' => [ 'title' => __('label.new.upload'), 'layout' => [ 'target' => 'components.upload', 'data' => [ 'id' => 'mediaManager', // INPUT ID BIND 'target' => 'product.cover.store', 'refs' => [ // RELATED OBJECTS 'modal' => 'mediaManagerContainerModal', // CONTAINER MODAL ], ], ] ], ], ]) @push('script') @endpush