<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace App\Models\System;

use Illuminate\Database\Eloquent\Casts\Attribute;

class Client extends \App\Models\BaseModel {

	protected $table = 'system_client';
	protected $fillable = ['title', 'app_id', 'secret', 'redirect', 'status'];

	protected function casts(): array {
		return [
			'status' => 'integer',
		];
	}

	public function appId() : Attribute {
		return Attribute::make(
			set: function (mixed $value, array $data){
				return uniqid();
			}
		);
	}

	public function secret() : Attribute {
		return Attribute::make(
			set: function (mixed $value, array $data){
				return md5(uniqid());
			}
		);
	}
}
