start guest invitation on event

This commit is contained in:
2020-08-09 20:45:41 +02:00
parent fa6d769daa
commit ec837fdb0a
8 changed files with 194 additions and 0 deletions

View File

@@ -2,9 +2,18 @@
namespace App\Models;
use App\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Event extends Model
{
protected $guarded = [];
public function guests() :BelongsToMany
{
return $this->belongsToMany(User::class, 'event_guest')
->withPivot('is_staff', 'validated_at')
->withTimestamps();
}
}

View File

@@ -8,12 +8,14 @@ use App\Models\Image;
use App\Models\Memo;
use App\Models\ToDoList;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;
use phpDocumentor\Reflection\Types\Boolean;
class User extends Authenticatable
{
@@ -110,4 +112,11 @@ class User extends Authenticatable
{
return $this->hasMany(Event::class);
}
public function invitedEvent(): BelongsToMany
{
return $this->belongsToMany(Event::class, 'event_guest')
->withPivot('is_staff', 'validated_at')
->withTimestamps();
}
}