mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 05:14:04 +00:00
Fix content, add command, update readme
This commit is contained in:
parent
3c3a5fcfd9
commit
69d86147d7
12 changed files with 70 additions and 35 deletions
35
app/Console/Commands/AddTweet.php
Normal file
35
app/Console/Commands/AddTweet.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Thread;
|
||||
use App\Models\Tip;
|
||||
use App\Twitter\Tweet;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class AddTweet extends Command
|
||||
{
|
||||
protected $signature = 'tweet:add {tweet}';
|
||||
|
||||
protected $description = 'Add a tweet';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$id = Str::of($this->argument('tweet'))->afterLast('/')->before('?');
|
||||
|
||||
$this->line('Fetching tweet ID ' . $id);
|
||||
|
||||
$tip = Tip::fromTweet(
|
||||
$tweet = Tweet::fetch($id)
|
||||
);
|
||||
|
||||
$tip->slug = $this->ask('Slug', $tip->defaultSlug());
|
||||
|
||||
$tip->thread_slug = $this->choice('Thread', Thread::all()->pluck('slug', 'title')->prepend('- None - ', null)->toArray(), null);
|
||||
|
||||
$tip->save();
|
||||
|
||||
$this->info("Successfully saved tip to: content/tips/{$tip->slug}.md");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue