Skip to content

Laravel storage link won’t work on production

I’m using storage_path to save my images and I symbolic my storage folder to public_html On the local everything works fine, when I upload an image it will upload in storage folder and link of it will appear in public folder but since I moved to live host and production mode my images will upload in sto…

Accessor for relation objects in Laravel

this is my Category model: and when i call it in route for get all object like this: it seems accessor not work and i can’t get ‘Foo’ in category’s media object Answer You can use withDefault(): When there is no result, it returns a Media instance with the given attributes.

Find first duplicate in an array

Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a smaller index than the second…