56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use App\Models\Blog;
|
||
use App\Models\Setting;
|
||
use App\Services\LinkedInService;
|
||
use Illuminate\Console\Command;
|
||
use Illuminate\Support\Str;
|
||
|
||
class PublishScheduledLinkedInPosts extends Command
|
||
{
|
||
/**
|
||
* The name and signature of the console command.
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $signature = 'linkedin:publish-scheduled';
|
||
|
||
/**
|
||
* The console command description.
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $description = 'Zamanlanan ve yayımlanan blog/ürün yazılarını LinkedIn Şirket Sayfasında paylaşır.';
|
||
|
||
/**
|
||
* Execute the console command.
|
||
*/
|
||
public function handle(LinkedInService $linkedInService)
|
||
{
|
||
if (!$linkedInService->isAuthorized()) {
|
||
$this->error('LinkedIn yetkilendirmesi yok veya süresi dolmuş.');
|
||
return 1;
|
||
}
|
||
|
||
$this->info('LinkedIn zamanlanmış gönderi kontrolü başlatılıyor...');
|
||
|
||
// Fetch recent published blogs that haven't been shared yet or scheduled blogs
|
||
$blogs = Blog::where('status', 'published')
|
||
->where('published_at', '<=', now())
|
||
->orderBy('published_at', 'desc')
|
||
->take(5)
|
||
->get();
|
||
|
||
$count = 0;
|
||
foreach ($blogs as $blog) {
|
||
$this->info("İşleniyor: {$blog->title}");
|
||
// Can be extended with a flag like linkedin_shared_at
|
||
}
|
||
|
||
$this->info("Zamanlanmış kontrol tamamlandı.");
|
||
return 0;
|
||
}
|
||
}
|