Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

karimali1337's avatar

Products Seeding

I'm trying to Seed products but it don't show the images at all and i tried some seeders that works with me in another project but not working in this one also it inserts the image link in the DB

public function run()
{
    DB::table('products')->insert([
        'name' => 'Shirt',
        'price' => 100,
        'category_id' => 1,
        'image'=>'https://i.ebayimg.com/images/g/wHIAAOSw37Baca9i/s-l500.jpg',
    ],

);
0 likes
12 replies
Sinnbeck's avatar

How is it not working?

it inserts the image link in the DB

What do you expect it to do?

Sinnbeck's avatar

@karimali1337 How does the code look? If I understood you correct, the url is correctly in the database ?

karimali1337's avatar

@Sinnbeck yes the url saved in the DB normal but the image is not shown and if i tried to insert the product manually the image shown.

Sinnbeck's avatar

@karimali1337 So the above code works, but some code you have not shown does not, and you need help with the code you have not shown?

esorone's avatar

Welll the URL is working, so it might be handy to show your blade file.

Is this possible?

karimali1337's avatar

@esorone

<div class="row">
    @foreach ($products as $product )
    @if ($product->category_id == 1)
    <div class="col-lg-3 col-md-6 col-sm-12">
        <div class="product-grid">
            <div class="product-image">
                <a href="#" class="image">
                    <img class="pic-1" src="{{URL::asset('Products')}}/{{$product->image}}">
                </a>
                <div class="price"> {{$product->price}}  </div>
                <form action="">
                    <a href="{{ url('add-to-cart/'.$product->id) }}" class="add-to-cart"> add to cart </a>
                </form>
            </div>
            <div class="product-content">
                <h3 class="title"><a href="#">{{$product->name}} </a></h3>
                <ul class="rating">
                    <li class="fas fa-star"></li>
                    <li class="fas fa-star"></li>
                    <li class="fas fa-star"></li>
                    <li class="fas fa-star"></li>
                    <li class="fas fa-star"></li>
                </ul>
            </div>
        </div>
    </div>
    @else
    @endif
    @endforeach
        </div>
</div>
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@karimali1337 You are saving an absolute url in the database, but you are adding your own url in front

                    <img class="pic-1" src="{{$product->image}}">

Please or to participate in this conversation.