Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

spatie/freek.dev

636 stars
2 code files
View spatie/freek.dev on GitHub

app/Jobs/TweetPostJob.php

Open in GitHub
use 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 GitHub
use 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();
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.