Currency Api Dashboard

TypeScript

Modern currency exchange rate dashboard with real-time market data, conversion tools, analytics, historical trends, and responsive admin interface.

Stars
18
Forks
1
Downloads
N/A
Open Issues
0
Files main

Repository Files

Loading file structure...
app/Models/Tokens.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Cache;

class Tokens extends Model
{
    protected $fillable = [
        'user_id',
        'name',
        'token',
        'default_currency',
        'active',
    ];

    protected $casts = [
        'active' => 'boolean',
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function logs(): HasMany
    {
        return $this->hasMany(ApiLog::class, 'token_id');
    }

    protected static function booted(): void
    {
        static::deleting(function ($token) {
            Cache::forget('TOKEN:'.$token->token);
        });
        static::updating(function ($token) {
            Cache::forget('TOKEN:'.$token->token);
        });
    }
}