-
app/Jobs/TweetPostJob.php
Open in GitHubuse App\Models\Post; use App\Services\Twitter\Twitter; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; class TweetPostJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public function handle(Twitter $twitter) { $tweetResponse = $twitter->tweet($tweetText); $tweetUrl = "https://twitter.com/freekmurze/status/{$tweetResponse['id_str']}"; } }
-
app/Actions/PublishPostAction.php
Open in GitHubuse App\Jobs\CreateOgImageJob; use App\Jobs\TweetPostJob; use App\Models\Post; use Illuminate\Support\Facades\Bus; class PublishPostAction { public function execute(Post $post) { $post->published = true; $post->save(); Bus::chain([ new TweetPostJob($post), ])->dispatch(); } }