Files
filament-short-url/src/Models/ShortUrlDailyStats.php
Bartłomiej Janczak eda4794cac feat: v1.2.0 — password protection, warning pages, smart targeting, rate limiting, daily stats aggregation
- Add password-protected links with session-based unlock flow
- Add redirect warning (interstitial) pages before external URLs
- Add smart targeting rules: device-based, country/geo, A/B weighted rotation
- Add configurable per-IP rate limiting with 429 + Retry-After headers
- Add daily stats aggregation & log pruning (short-url:aggregate-and-prune)
- Add IncrementVisitJob as queue-based counter buffering fallback
- Add ShortUrlDailyStats model with JSON stat columns per day
- Add two new migrations: targeting/security fields, daily_stats table
- Add password-prompt.blade.php and warning.blade.php views
- Extend Settings GUI with Performance & Security tab (aggregation + rate limiting)
- Extend ShortUrlForm with Targeting & Security section
- Add POST route for password form submission (was GET-only → 405)
- Replace enum(device_type) with string(20) for cross-DB compatibility
- Remove ->after() MySQL-only hints from ALTER TABLE migrations
- Fix aggregation test: use whereDate() instead of assertDatabaseHas for date column
- Extend en/pl translations for all new features
- Expand README.md with full v1.2.0 documentation (476 lines)
2026-06-01 13:54:13 +02:00

68 lines
1.8 KiB
PHP

<?php
namespace Bjanczak\FilamentShortUrl\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
/**
* @property int $id
* @property int $short_url_id
* @property Carbon $date
* @property int $visits_count
* @property int $unique_visits_count
* @property array|null $device_stats
* @property array|null $browser_stats
* @property array|null $os_stats
* @property array|null $country_stats
* @property array|null $city_stats
* @property array|null $referer_stats
* @property array|null $utm_source_stats
* @property array|null $utm_medium_stats
* @property array|null $utm_campaign_stats
* @property Carbon $created_at
* @property Carbon $updated_at
*/
class ShortUrlDailyStats extends Model
{
protected $table = 'short_url_daily_stats';
protected $fillable = [
'short_url_id',
'date',
'visits_count',
'unique_visits_count',
'device_stats',
'browser_stats',
'os_stats',
'country_stats',
'city_stats',
'referer_stats',
'utm_source_stats',
'utm_medium_stats',
'utm_campaign_stats',
];
/** @var array<string, string> */
protected $casts = [
'date' => 'date',
'visits_count' => 'integer',
'unique_visits_count' => 'integer',
'device_stats' => 'array',
'browser_stats' => 'array',
'os_stats' => 'array',
'country_stats' => 'array',
'city_stats' => 'array',
'referer_stats' => 'array',
'utm_source_stats' => 'array',
'utm_medium_stats' => 'array',
'utm_campaign_stats' => 'array',
];
public function shortUrl(): BelongsTo
{
return $this->belongsTo(ShortUrl::class, 'short_url_id');
}
}