Todo-Actions, Observer und Mails
This commit is contained in:
1 parent
9501d8f1c2
commit
be675ec81e
10 files changed
+247
-11
No files matched your search
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Observers\TodoObserver;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
@@ -21,4 +22,16 @@ class Todo extends Model
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function is_owner_or_assigned() {
|
||||
if(filament()->auth()->user()->id == $this->user_id) return true;
|
||||
if($this->todoable_type == Group::class && in_array(filament()->auth()->user()->id, $this->todoable()->first()->get()->users()->get()->pluck('id')->toArray())) return true;
|
||||
if($this->todoable_type == User::class && $this->todoable()->first()->get()->id == filament()->auth()->user()->id) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
public function getassignetusers() {
|
||||
if($this->todoable_type == Group::class) return $this->todoable()->first()->users()->get();
|
||||
if($this->todoable_type == User::class) return [$this->todoable()->first()->get()];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user