favorits ok
This commit is contained in:
1 parent
6cf075709e
commit
5ec3e9ef7c
6 files changed
+130
-3
No files matched your search
@@ -57,7 +57,8 @@ class EventResource extends Resource
|
||||
->with('competition_group')
|
||||
->with('country')
|
||||
->with('home')
|
||||
->with('away');
|
||||
->with('away')
|
||||
->with('event_user_star');
|
||||
|
||||
if (in_array('odds_2ways', EventsTable::$bettype_settings)) {
|
||||
$query->with('odds_2ways.bookmaker');
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Filament\Tables\Columns\MatchIds;
|
||||
use App\Models\BettypeUser;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventUserStar;
|
||||
use App\Models\MultilineClient;
|
||||
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
|
||||
use Filament\Actions\Action;
|
||||
@@ -28,6 +29,7 @@ use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\VerticalAlignment;
|
||||
@@ -47,6 +49,10 @@ class EventsTable
|
||||
|
||||
public static $multiline_gettype = [];
|
||||
|
||||
protected $listeners = [
|
||||
'example' => '$refresh',
|
||||
];
|
||||
|
||||
public static function load_multiline_bookmaker()
|
||||
{
|
||||
$res = MultilineClient::with('multiline_setting')
|
||||
@@ -262,6 +268,12 @@ class EventsTable
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->live(),
|
||||
Toggle::make('stars_status')
|
||||
->hiddenLabel()
|
||||
->onIcon('phosphor-star-fill')
|
||||
->offIcon('phosphor-star')
|
||||
->offColor('gray')
|
||||
->live(),
|
||||
Action::make('resetAction')
|
||||
->hiddenLabel()
|
||||
->color('primary')
|
||||
@@ -275,6 +287,10 @@ class EventsTable
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['stars_status'],
|
||||
fn (Builder $query) => $query->whereHas('event_user_star')
|
||||
)
|
||||
->when(
|
||||
$data['country_id'],
|
||||
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
|
||||
@@ -305,12 +321,35 @@ class EventsTable
|
||||
}
|
||||
);
|
||||
})
|
||||
->columns(19)->columnSpan(19),
|
||||
->columns(20)->columnSpan(20),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->filtersFormColumns(6)
|
||||
->deferFilters(false)
|
||||
->persistFiltersInSession()
|
||||
->recordActions([
|
||||
Action::make('star')
|
||||
->iconButton()
|
||||
// ->color('gray')
|
||||
->icon(function ($record) {
|
||||
if (isset($record->event_user_star->id)) {
|
||||
return 'phosphor-star-fill';
|
||||
} else {
|
||||
// dd($record->event_user_stars);
|
||||
|
||||
return 'phosphor-star';
|
||||
}
|
||||
})
|
||||
->tooltip('Add to favorits')
|
||||
->action(function ($record) {
|
||||
$res = EventUserStar::where('event_id', $record->id)
|
||||
->where('user_id', auth()->user()->id)
|
||||
->first();
|
||||
if ($res) {
|
||||
EventUserStar::find($res->id)->delete();
|
||||
} else {
|
||||
EventUserStar::insert(['event_id' => $record->id, 'user_id' => auth()->user()->id]);
|
||||
}
|
||||
}),
|
||||
ActionGroup::make([
|
||||
// EditAction::make(),
|
||||
DeleteAction::make()->visible(fn () => auth()->user()->hasRole('super_admin')),
|
||||
|
||||
@@ -137,4 +137,9 @@ class Event extends Model
|
||||
{
|
||||
return $this->hasMany(OddsTq::class);
|
||||
}
|
||||
|
||||
public function event_user_star()
|
||||
{
|
||||
return $this->hasOne(EventUserStar::class, 'event_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EventUserStar extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'event_id',
|
||||
'user_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
use App\Models\TxoddsMarket;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class TxoddsMarketPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:TxoddsMarket');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, TxoddsMarket $txoddsMarket): bool
|
||||
{
|
||||
return $authUser->can('View:TxoddsMarket');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:TxoddsMarket');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, TxoddsMarket $txoddsMarket): bool
|
||||
{
|
||||
return $authUser->can('Update:TxoddsMarket');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, TxoddsMarket $txoddsMarket): bool
|
||||
{
|
||||
return $authUser->can('Delete:TxoddsMarket');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, TxoddsMarket $txoddsMarket): bool
|
||||
{
|
||||
return $authUser->can('Restore:TxoddsMarket');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, TxoddsMarket $txoddsMarket): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:TxoddsMarket');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:TxoddsMarket');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:TxoddsMarket');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, TxoddsMarket $txoddsMarket): bool
|
||||
{
|
||||
return $authUser->can('Replicate:TxoddsMarket');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:TxoddsMarket');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,6 @@ return new class extends Migration
|
||||
$table->text('app_authentication_secret')->nullable();
|
||||
$table->text('app_authentication_recovery_codes')->nullable();
|
||||
$table->boolean('has_email_authentication')->default(false);
|
||||
$table->boolean('stars_status')->default(false);
|
||||
$table->timestamp('app_verified_at')->nullable();
|
||||
|
||||
$table->rememberToken();
|
||||
|
||||
Reference in new issue
Block a user