This error is comes when get the image from another table...
This is my controller
namespace App\Http\Controllers;
use App\Category;
use App\SubCategory;
use App\mediaLibrary;
use DB;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class SubCategoryController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$subcat = SubCategory::with('category','mediaLibrary')->where('delete_status','=',1)->get();
$subcat= $subcat->toArray();
//dd($subcat);
$trash = SubCategory::where('delete_status','=',0)->count();
$cat = Category::all();
// $subcat = SubCategory::all();
return view('subcategory.index',compact('subcat','cat','trash'));
}
this is my blade file code
@foreach ($subcat as $subcat)
<tr>
<td width="20">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="checkbox custom-control-input" id="{{ $subcat['id'] }}" data-id="{{ $subcat['id'] }}">
<label class="custom-control-label ml-2" for="{{ $subcat['id'] }}"></label>
</div>
</td>
<td>{{ $subcat['category']['name'] }}</td>
<td><img src="{{url('uploads/article/Category/'.$subcat['category']['image'] )}}" class="rounded border" style="height:36px;" /></td>
<td>{{ $subcat['subcategory_name'] }}</td>
<td><img src="{{url($subcat['mediaLibrary']['filename'] )}}" class="rounded border" style="height: 36px;" /></td>
@endforeach
should I remove th toArray() ?