JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr{ gilour

File "BiolinkLink.php"

Full Path: /home/markqprx/iniasli.pro/app-20260222054640/Models/BiolinkLink.php
File size: 1.95 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Models;

use App\Actions\Link\LinkeablePublicPolicy;
use Illuminate\Database\Eloquent\Casts\Attribute;

class BiolinkLink extends Link
{
    public $table = 'links';

    protected $eagerLoad = ['rules', 'tags', 'pixels', 'domain'];
    protected $hidden = ['pivot', 'password'];
    protected $appends = [
        'position',
        'animation',
        'leap_until',
        'active_locked',
        'short_url',
        'has_password',
        'model_type',
    ];
    protected $casts = [
        'id' => 'integer',
        'domain_id' => 'integer',
        'user_id' => 'integer',
        'active' => 'boolean',
        'has_password' => 'boolean',
        'position' => 'int',
        'expires_at' => 'datetime',
        'clicked_at' => 'datetime',
        'activates_at' => 'datetime',
        'leap_until' => 'datetime',
    ];

    protected function position(): Attribute
    {
        return Attribute::make(
            get: fn($value, $attributes) => $this->pivot->position,
        );
    }

    protected function animation(): Attribute
    {
        return Attribute::make(
            get: fn($value, $attributes) => $this->pivot->animation,
        );
    }

    protected function leapUntil(): Attribute
    {
        return Attribute::make(
            get: fn($value, $attributes) => $this->pivot->leap_until,
        );
    }

    protected function activeLocked(): Attribute
    {
        return Attribute::make(
            get: function (): bool {
                if (
                    LinkeablePublicPolicy::linkeableExpired($this) ||
                    LinkeablePublicPolicy::linkeableWillActivateLater($this)
                ) {
                    return true;
                }
                return false;
            },
        );
    }

    protected function active(): Attribute
    {
        return Attribute::make(
            get: fn($value, $attributes) => !$this->active_locked &&
                (bool) $value,
        );
    }
}