Home > Enterprise >  Hide a video player if there is no data in database
Hide a video player if there is no data in database

Time:10-18

How do I hide a video player if there is no data to be displayed? enter image description here

Do I need to use javascript for it?

Here is the code for displaying the video player:

        <div id="video-player"> 
        <video width="100%"controls> 
            <source src="{{ asset('workmedia/' . $artpiece->art_vid) }}" type="video/mp4"> 
              Your browser does not support the video tag. 
        </video> 
      </div>

CodePudding user response:

Use the @isset blade directive to determine if your $artpiece->art_vid has a value and if it does, display the video otherwise don't:

@isset($artpiece->art_vid)
<div id="video-player"> 
        <video width="100%"controls> 
            <source src="{{ asset('workmedia/' . $artpiece->art_vid) }}" type="video/mp4"> 
              Your browser does not support the video tag. 
        </video> 
      </div>
@endisset
  • Related