26 lines
682 B
PHP
26 lines
682 B
PHP
<?php
|
|
|
|
namespace App\Actions;
|
|
|
|
use App\Models\Route;
|
|
|
|
class CreateRouteAction
|
|
{
|
|
/**
|
|
* Create a route or return an existing one for the same feed+channel pair.
|
|
* When a route already exists, the provided priority and isActive values are ignored.
|
|
*/
|
|
public function execute(int $feedId, int $platformChannelId, int $priority = 0, bool $isActive = true): Route
|
|
{
|
|
return Route::firstOrCreate(
|
|
[
|
|
'feed_id' => $feedId,
|
|
'platform_channel_id' => $platformChannelId,
|
|
],
|
|
[
|
|
'priority' => $priority,
|
|
'is_active' => $isActive,
|
|
]
|
|
);
|
|
}
|
|
}
|