global storage-providers, notification channels and server providers (#247)

This commit is contained in:
Saeed Vaziry
2024-06-29 12:52:03 +03:30
committed by GitHub
parent ad027eb033
commit 11e3b167cc
44 changed files with 678 additions and 77 deletions

View File

@ -3,7 +3,9 @@
namespace App\Models;
use App\Notifications\NotificationInterface;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Notifications\Notifiable;
/**
@ -12,6 +14,7 @@
* @property array data
* @property string label
* @property bool connected
* @property int $project_id
*/
class NotificationChannel extends AbstractModel
{
@ -24,6 +27,7 @@ class NotificationChannel extends AbstractModel
'data',
'connected',
'is_default',
'project_id',
];
protected $casts = [
@ -47,4 +51,16 @@ public static function notifyAll(NotificationInterface $notification): void
$channel->notify($notification);
}
}
public function project(): BelongsTo
{
return $this->belongsTo(Project::class);
}
public static function getByProjectId(int $projectId): Builder
{
return self::query()
->where('project_id', $projectId)
->orWhereNull('project_id');
}
}