I have a problem, I can not solve this problem about showing content in my view. I have a table in my database called galleries:
- idGaleria
- url
- UserID
What I record in that table is the url where I store the file, either photos or videos. This part of uploading images and videos already works for me, the problem is that now I want to visualize all that content in a view, but the only problem is when I go through the table, I visualize everything in an img tag, but if it's a video obviously I do not will recognize, then the only solution I found was from the controller check if it is an image that saves everything in a variable $ images and if it is video in $ videos, this should be displayed my view blade, but the only problem I have is how I must verify if it is a video or image. I do not know if they can understand me In my view I have this code to view 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 I visualize everything in the img tag, that's why I said that in the controller I made two variables to separate the images and videos from the routes.
Code of my index driver, 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 that would be something like this:
/imagenes/5c2db5a7705b520631811_1425711934186283_992917833_n.jpg