-
app/Http/Controllers/Submission/SubmitStreamController.php
Open in GitHubuse App\Actions\Submission\SubmitStreamAction; use App\Http\Requests\SubmitStreamRequest; class SubmitStreamController { public function __invoke(SubmitStreamRequest $request, SubmitStreamAction $submitStream) { $submitStream->handle($request->youtube_id, $request->email); return response()->noContent(); } }
-
app/Actions/Submission/SubmitStreamAction.php
Open in GitHubuse App\Actions\ImportVideoAction; use App\Mail\StreamSubmittedMail; use Illuminate\Support\Facades\Mail; class SubmitStreamAction { public function handle(string $youTubeId, string $languageCode, string $submittedByEmail) { $stream = app(ImportVideoAction::class)->handle( $youTubeId, $languageCode, approved: false, submittedByEmail: $submittedByEmail, ); Mail::to('christoph@christoph-rumpel.com')->queue(new StreamSubmittedMail($stream)); } }
-
app/Actions/ImportVideoAction.php
Open in GitHubuse App\Facades\Youtube; use App\Models\Stream; class ImportVideoAction { public function handle( string $youTubeId, string $languageCode = 'en', $approved = false, ?string $submittedByEmail = null, ): Stream { $video = Youtube::video($youTubeId); return Stream::updateOrCreate(['youtube_id' => $video->videoId], [ 'channel_title' => $video->channelTitle, 'title' => $video->title, 'description' => $video->description, 'thumbnail_url' => $video->thumbnailUrl, 'scheduled_start_time' => $video->plannedStart, 'language_code' => $languageCode, 'status' => $video->status, 'approved_at' => $approved ? now() : null, 'submitted_by_email' => $submittedByEmail, ]); } }