tissue/app/CheckinWebhook.php

40 lines
755 B
PHP
Raw Normal View History

2020-07-19 18:39:19 +09:00
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
2020-07-24 12:02:27 +09:00
use Illuminate\Database\Eloquent\SoftDeletes;
2020-07-19 18:39:19 +09:00
use Illuminate\Support\Str;
class CheckinWebhook extends Model
{
2020-07-24 12:02:27 +09:00
use SoftDeletes;
2020-07-23 22:36:08 +09:00
/** @var int ユーザーごとの作成数制限 */
const PER_USER_LIMIT = 10;
2020-07-19 18:39:19 +09:00
public $incrementing = false;
protected $keyType = 'string';
protected $fillable = ['name'];
protected static function boot()
{
parent::boot();
self::creating(function (CheckinWebhook $webhook) {
$webhook->id = Str::random(64);
});
}
public function user()
{
return $this->belongsTo(User::class);
}
2020-07-19 23:04:10 +09:00
public function isAvailable()
{
2020-07-24 13:56:06 +09:00
return $this->user !== null;
2020-07-19 23:04:10 +09:00
}
2020-07-19 18:39:19 +09:00
}