I have a problem, I can't solve this problem about displaying content in my view. I have a table in my database called galleries:
- idGallery
- URL
- userid
What I register in that table is the url where I store the file, be it photos or videos. This part of uploading images and videos already works for me, the problem is that now I want to display all that content in a view, but the only problem is when I go through the table, I display everything in an img tag, but if it is a video obviously I don't It will recognize, so the only solution I found was from the controller to verify if it is an image that saves everything in a variable $images and if it is a video in $videos, this should be displayed in my blade view, but the only problem I have is like I must verify if it is a video or image. I don't know if they can understand me. In my view I have this code to display the content of the query from the controller using the index method;
<div class="card">
<div class="card-body">
<h5 class="card-title">Mi galeria</h5>
<hr>
<div class="row" >
@foreach ($galerias as $galeria)
<div class="col-12 col-md-2" style="height:100px; margin-bottom: 10px;" >
<div class="card" style=" height:100%;">
@if($galeria->url)
<img src="{{ url($galeria->url) }}" class="card-img-top" style="height:100%;">
@endif
</div>
</div>
@endforeach
</div>
</div>
</div>
And as a result of the view, I get this:
The only problem is when I go through the variable, everything is displayed in the img tag, that's why I said that in the controller make two variables to separate the images and videos from the routes.
Code of my index controller, which is not very important
public function index()
{
$galerias= Galeria::get();
return view('vistaGaleria',compact('galerias'));
}
In the database, the only thing I store is the url, which would be something like this:
/imagenes/5c2db5a7705b520631811_1425711934186283_992917833_n.jpg
with the extension at the end of the file url you can differentiate between video or image: