mirror of
https://github.com/flarum/framework.git
synced 2025-02-28 16:17:40 +08:00
41 lines
777 B
PHP
41 lines
777 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Flarum\Api;
|
|
|
|
use Flarum\Database\AbstractModel;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $key
|
|
* @property string|null $allowed_ips
|
|
* @property string|null $scopes
|
|
* @property int|null $user_id
|
|
* @property \Carbon\Carbon $created_at
|
|
* @property \Carbon\Carbon|null $last_activity_at
|
|
*/
|
|
class ApiKey extends AbstractModel
|
|
{
|
|
/**
|
|
* Generate an API key.
|
|
*
|
|
* @return static
|
|
*/
|
|
public static function generate()
|
|
{
|
|
$key = new static;
|
|
|
|
$key->key = str_random(40);
|
|
|
|
return $key;
|
|
}
|
|
}
|