7 months ago

Passing data object from blade to modal in Laravel

Posted 7 months ago by albusSeverus

Im pulling multiple data objects from controller to the blade template and then passing that information to each modal popup for further user interaction, I do have some conditional checking.

Problem is how do I pass my object to the modal directly and do the conditional formatting?

Modal Code

<div class="modal-footer">
        <!-- Add condition to see if user has already applied to this opening or not -->
        @foreach ($applied as $user_applied)
            @if($user_applied->opening_id == $opening->id) 
              <button type="button" class="btn btn-primary" disabled="disabled">Applied </button>
              <button type="button" data-id="{{$opening->id}}" id="application" data-create-url="{{ route('applicants.bookmarks.openings.apply', $opening->id) }}" class="btn btn-primary">Apply <span class="glyphicon glyphicon-send" aria-hidden="true"></span></button>
        <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>

Controller Code

return view('applicants.bookmarks.openings', compact('openings', 'bookmarks', 'applied'));

View Code

@each('applicants.bookmarks.opening-modal', $openings, 'opening')

Please sign in or create an account to participate in this conversation.