37 lines
		
	
	
		
			689 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			689 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App;
 | 
						|
 | 
						|
use Illuminate\Database\Eloquent\Model;
 | 
						|
use Illuminate\Support\Str;
 | 
						|
 | 
						|
class CheckinWebhook extends Model
 | 
						|
{
 | 
						|
    /** @var int ユーザーごとの作成数制限 */
 | 
						|
    const PER_USER_LIMIT = 10;
 | 
						|
 | 
						|
    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);
 | 
						|
    }
 | 
						|
 | 
						|
    public function isAvailable()
 | 
						|
    {
 | 
						|
        return $this->user() !== null;
 | 
						|
    }
 | 
						|
}
 |