sant0ro/chocolatey

View on GitHub
app/Models/TrustedDevice.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace App\Models;

/**
 * Class TrustedDevice.
 */
class TrustedDevice extends ChocolateyModel
{
    /**
     * Disable Timestamps.
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'chocolatey_users_security_trusted';

    /**
     * Primary Key of the Table.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = ['id'];

    /**
     * Store a new TrustedDevice.
     *
     * @param int    $userId
     * @param string $ipAddress
     *
     * @return TrustedDevice
     */
    public function store(int $userId, string $ipAddress): self
    {
        $this->attributes['user_id'] = $userId;
        $this->attributes['ip_address'] = $ipAddress;
        $this->timestamps = false;

        $this->save();

        return $this;
    }
}