jeudi 9 décembre 2021

Laravel : Generate a random url, recover the new url after processing

With laravel I created a function to have an image + a random id from 0 to 30. Unfortunately the image stored in my database is not processed and is listed in my database like this: https://source.unsplash.com/800x800/?portrait=28 How can I solve this I have not found anything yet.

my Factory :

'profile_photo_path' => $this->loadImage(),

my function :

public function loadImage()
    {
        return "https://source.unsplash.com/800x800/?portrait=" . mt_rand(1, 30);
    }

When you click you get a different url.

example : https://images.unsplash.com/photo-1552699611-e2c208d5d9cf?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=800&ixid=MnwxfDB8MXxyYW5kb218MHx8cG9ydHJhaXR8fHx8fHwxNjM5MDU5Njkw&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=800

this is what I want to enter in the database




Aucun commentaire:

Enregistrer un commentaire