@extends('layouts/fams_layout') @section('title', '| Brand') @section('content') @php $brandIdsFromProductTable = DB::table('fams_product')->distinct()->pluck('brandId')->toArray(); $brandIdsFromModelTable = DB::table('fams_product_model')->distinct()->pluck('productBrandId')->toArray(); $foreignBrandIds = array_merge($brandIdsFromProductTable, $brandIdsFromModelTable); $foreignBrandIds = array_unique($foreignBrandIds); @endphp

BRANDS

{{ csrf_field() }} @foreach($productBrands as $productBrand) @php $isBelongToProduct = DB::table('fams_product')->where('brandId',$productBrand->id)->value('id'); $isBelongToModel = DB::table('fams_product_model')->where('productBrandId',$productBrand->id)->value('id'); $allowedToDelete = max($isBelongToProduct,$isBelongToModel); @endphp @endforeach
SL# Name Action
{{++$no}} {{$productBrand->name}}   @php if (in_array($productBrand->id, $foreignBrandIds)) { $canDelete = 0; } else{ $canDelete = 1; } @endphp
@foreach($productBrands as $prodBrand) {{-- Edit Modal --}} {{-- End Edit Modal --}} {{-- Delete Modal --}} {{-- End Delete Modal --}} {{-- Update data --}} @endforeach @include('dataTableScript') @endsection