mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 03:04:05 +00:00
33 lines
590 B
PHP
33 lines
590 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use App\Mail\InvitationEmail;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Invitation extends Model
|
|
{
|
|
protected $guarded = [];
|
|
|
|
public static function findByCode($code)
|
|
{
|
|
return self::where('code', $code)->firstOrFail();
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function hasBeenUsed()
|
|
{
|
|
return $this->user_id !== null;
|
|
}
|
|
|
|
public function send()
|
|
{
|
|
Mail::to($this->email)->send(new InvitationEmail($this));
|
|
}
|
|
}
|