jcadima
6/12/2018 - 4:11 PM

Laravel Toggle table add/edit

https://stackoverflow.com/questions/6204541/jquery-toggle-show-hide

http://jsfiddle.net/fd8ZS/397/

<tbody>

    @forelse( $videos as $video )
        <tr class="view">
            <td><img src="https://img.youtube.com/vi/{{ $video->youtube_id }}/1.jpg"></p></td>
            <td>{{ $video->id }}</td>
            <td>{{ $video->youtube_name }}</td>
            <td>
                <a class="toggle btn btn-default" href="#">Edit</a>
                <a href="{{ route('video.show', ['id' => $video->id]) }}" class="btn btn-custom"> <i class="fa fa-eye" aria-hidden="true"></i> </a>
            </td>
        </tr>

        <tr class="edit" style="display:none">
            <td>
                <form id="project_form" action="{{ route('video.edit', ['id' => $video->id ]) }}" method="POST">  
                <div class="form-group">
                    <select class="form-control" id="category_id" name="category_id">
                        <option selected="true" disabled="disabled">Select Category</option> 
                        @foreach( $categories as $category ) 
                        <option value="{{ $category->id }}" {{ ( $category->id == $video->category_id) ? ' selected' : '' }}>{{ $category->name }}</option>
                        @endforeach
                    </select>
                </div>
                </div>
                <input class="btn btn-custom" type="submit" value="Submit" >
                <a class="cancel btn btn-default" href="#">Cancel</a>
            </td>
        </tr>                        

    @empty
        <tr>
            <th colspan="5" class="text-center">There are no videos.</th>
        </tr>
    @endforelse

</tbody>