Raise PHPStan level
This commit is contained in:
parent
195471f8a9
commit
26187e2dd9
5 changed files with 15 additions and 8 deletions
|
|
@ -100,6 +100,6 @@ public function setActive(PlatformAccount $platformAccount): RedirectResponse
|
||||||
$platformAccount->setAsActive();
|
$platformAccount->setAsActive();
|
||||||
|
|
||||||
return redirect()->route('platforms.index')
|
return redirect()->route('platforms.index')
|
||||||
->with('success', "Set $platformAccount->username@$platformAccount->instance_url as active for $platformAccount->platform!");
|
->with('success', "Set $platformAccount->username@$platformAccount->instance_url as active for {$platformAccount->platform->value}!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Feed;
|
use App\Models\Feed;
|
||||||
|
use App\Models\FeedPlatformChannel;
|
||||||
use App\Models\PlatformChannel;
|
use App\Models\PlatformChannel;
|
||||||
use App\Services\RoutingValidationService;
|
use App\Services\RoutingValidationService;
|
||||||
use App\Exceptions\RoutingMismatchException;
|
use App\Exceptions\RoutingMismatchException;
|
||||||
|
|
@ -127,15 +128,15 @@ public function destroy(Feed $feed, PlatformChannel $channel): RedirectResponse
|
||||||
|
|
||||||
public function toggle(Request $request, Feed $feed, PlatformChannel $channel): RedirectResponse
|
public function toggle(Request $request, Feed $feed, PlatformChannel $channel): RedirectResponse
|
||||||
{
|
{
|
||||||
$routing = $feed->channels()
|
$routing = FeedPlatformChannel::where('feed_id', $feed->id)
|
||||||
->wherePivot('platform_channel_id', $channel->id)
|
->where('platform_channel_id', $channel->id)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (! $routing) {
|
if (! $routing) {
|
||||||
abort(404, 'Routing not found');
|
abort(404, 'Routing not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$newStatus = ! $routing->pivot->is_active;
|
$newStatus = ! $routing->is_active;
|
||||||
|
|
||||||
$feed->channels()->updateExistingPivot($channel->id, [
|
$feed->channels()->updateExistingPivot($channel->id, [
|
||||||
'is_active' => $newStatus,
|
'is_active' => $newStatus,
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,11 @@ public function platformAccounts(): BelongsToMany
|
||||||
->withTimestamps();
|
->withTimestamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function activePlatformAccounts(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->platformAccounts()->where('is_active', true);
|
||||||
|
}
|
||||||
|
|
||||||
public function getFullNameAttribute(): string
|
public function getFullNameAttribute(): string
|
||||||
{
|
{
|
||||||
// For Lemmy, use /c/ prefix. Other platforms may use different formats
|
// For Lemmy, use /c/ prefix. Other platforms may use different formats
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
use App\Exceptions\PublishException;
|
use App\Exceptions\PublishException;
|
||||||
use App\Models\Article;
|
use App\Models\Article;
|
||||||
use App\Models\ArticlePublication;
|
use App\Models\ArticlePublication;
|
||||||
|
use App\Models\PlatformChannel;
|
||||||
use App\Modules\Lemmy\Services\LemmyPublisher;
|
use App\Modules\Lemmy\Services\LemmyPublisher;
|
||||||
use App\Services\Log\LogSaver;
|
use App\Services\Log\LogSaver;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
@ -24,10 +25,10 @@ public function publishToRoutedChannels(Article $article, array $extractedData):
|
||||||
}
|
}
|
||||||
|
|
||||||
$feed = $article->feed;
|
$feed = $article->feed;
|
||||||
$activeChannels = $feed->activeChannels()->with(['platformInstance', 'platformAccounts'])->get();
|
$activeChannels = $feed->activeChannels()->with(['platformInstance', 'activePlatformAccounts'])->get();
|
||||||
|
|
||||||
return $activeChannels->map(function ($channel) use ($article, $extractedData) {
|
return $activeChannels->map(function (PlatformChannel $channel) use ($article, $extractedData) {
|
||||||
$account = $channel->platformAccounts()->where('is_active', true)->first();
|
$account = $channel->activePlatformAccounts()->first();
|
||||||
|
|
||||||
if (! $account) {
|
if (! $account) {
|
||||||
LogSaver::warning('No active account for channel', $channel, [
|
LogSaver::warning('No active account for channel', $channel, [
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ includes:
|
||||||
- vendor/larastan/larastan/extension.neon
|
- vendor/larastan/larastan/extension.neon
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
level: 0
|
level: 2
|
||||||
paths:
|
paths:
|
||||||
- app/
|
- app/
|
||||||
- tests/
|
- tests/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue