Check if the file is an image or a video in php format? using the laravel frame

I have a problem, I can not solve this problem of displaying content in my opinion.
I have a table in my database called galleries:

What I record in this table is the url where I store the file, whether photos or videos. This part of the download of images and videos already works for me, the problem is that I want to now view all this content in a view, but the only problem is that when I browse the table, I visualize everything in an img tag, but if it's a video, it's obviously not the case. will recognize, then the only solution I found was that of the controller if it's an image that records everything in a variable $ images and if it's a video in $ videos, it should be displayed in my viewing blade, but the only problem I have is how do I check if it's a video or an image. I do not know if they can understand me
In my opinion, I have this code to display the contents of the controller query using the method of indexing;

My gallery

@foreach ($ galleries as $ gallery)
@if ($ gallery-> url) enter the description of the image here

The only problem is that when I look at the variable, I visualize all the content of the img tag. That's why I said that in the controller, I had created two variables to separate images and videos from the roads.

Code of my driver index, which does not have a lot of importance

Public Service Index ()
$ galleries = Gallery :: get ();
back view (& # 39; vistaGaleria & # 39; compact (& # 39; galleries & # 39;));

In the database, the only thing I store is the URL that looks like this: