File: /home/armgroup/libs/resources/views/account/favorites/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container my-5 body-content">
<div class="row">
<div class="col-lg-3 col-sm-12">
@include('account.sidebar')
</div>
<div class="col-lg-9 col-sm-12">
<div class="card">
<h5 class="card-header">{{ __('Favorites') }}
<span class="float-end">
<form action="{{ route('account.favorites.index') }}"
id="favorite_form" method="GET">
<select name="type" id="favorite_type" class="form-control form-select">
<option value="">تمام علاقهمندیها</option>
@foreach(\App\Models\Favorite::TYPE as $type)
<option value="{{ $type['show-name'] }}"
{{ request('type') == $type['show-name'] ? 'selected' : '' }}>
{{ $type['name'] }}
</option>
@endforeach
</select>
</form>
</span>
</h5>
<div class="card-body">
<table class="table table-sm">
<thead class="thead-dark">
<tr>
<th scope="col">{{ __('Title') }}</th>
<th scope="col">{{ __('Date') }}</th>
<th scope="col">{{ __('Actions') }}</th>
</tr>
</thead>
<tbody>
@foreach($favorites as $favorite)
<tr>
<td>{{ $favorite->favoritable?->{$favorite->getFavoriteType()['title']} }}</td>
<td>{{ jdate($favorite->created_at) }}</td>
<td>
<form action="{{ route('account.favorites.destroy', $favorite->id) }}"
method="POST">
@csrf
@method('DELETE')
<a href="{{ optional($favorite->favoritable)->url }}"
class="btn btn-secondary btn-sm"
target="_blank">
<span class="fa fa-eye"></span> {{ $favorite->getFavoriteType()['show-name'] }}
</a>
<button type="submit" class="btn btn-danger btn-sm">
<span class="fa fa-trash"></span> {{ __('Delete') }}
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
{{ $favorites->links() }}
</div>
</div>
</div>
</div>
@endsection
@section('footer')
<script>
$(document).ready(function() {
$('#favorite_type').on('change', function() {
$('#favorite_form').submit();
});
});
</script>
@endsection