What's this constraint where('categories_id', '=', 'images_id')?
Aside from that, put everything in its right place.
Data needed by the view should be organized in the Controller action, and passed to the view rather than making Eloquent queries in the view template:
// controller action
$subcategories = SubCategories::where('categories_id', '=', 'images_id')->get(); // where clause means what?
Make an accessor method for computed properties on a Model instance. Here we will create an image computed property on each model instance:
// Model class
public function getImageAttribute()
{
return $this->thumbnail ?? 'default.jpg';
}
This greatly simplifies the view template - it is concerned only with presentation now:
@foreach($subcategories as $subcategory)
<li class="slide">
<a class="slink sq" href="{{ url('s',$subcategory->slug) }}"> <!-- is this correct -->
<img
height="80"
width="102"
loading="lazy"
class="img-circle sqtags"
src="{{asset('public/img-category/' . $subcategory->image) }}"
>
<div class="sidekro chapta">
<p>{{ $subcategory->name }}</p>
</div>
</a>
</li>
@endforeach