Skip to content

Tag: php

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…

Laravel 5.6 – User not getting authenticated

I have looked for days, but my user never gets authenticated when using the auth middleware. We don’t use the standard laravel way, but using the standard auth middleware to block access to a route group. (in this example the dashboards) The data is correct as it doesnt give any error message, but the u…

What does this $_SERVER[‘REQUEST_METHOD’] === ‘POST’ do?

A little new to php and reading some people’s code and saw this: I get what isset(…) is doing but don’t understand the what the first if statement. Especially because the if statement was working when my request method was GET but wasn’t when my request method was POST Answer say your …