Add (facebook)
This commit is contained in:
@@ -28,7 +28,7 @@ public function redirect(Request $request, $slug)
|
||||
|
||||
public function index(Request $request, $category_slug, $slug)
|
||||
{
|
||||
$post = Post::where('slug', $slug)->where('status', 'publish')->first();
|
||||
$post = Post::where('slug', $slug)->whereIn('status', ['publish','future'])->first();
|
||||
|
||||
if (is_null($post)) {
|
||||
return abort(404);
|
||||
|
||||
@@ -7,9 +7,21 @@
|
||||
use Illuminate\Http\Request;
|
||||
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
|
||||
use LaravelGoogleIndexing;
|
||||
use App\Models\Post;
|
||||
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use App\Notifications\PostWasPublished;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
|
||||
public function notification(Request $request)
|
||||
{
|
||||
$post = Post::find(1);
|
||||
|
||||
Notification::route('facebook','default')->notify(new PostWasPublished($post));
|
||||
}
|
||||
|
||||
public function imageGen(Request $request)
|
||||
{
|
||||
$image_url = 'https://cdn.futurewalker.co/post_images_2/whats-next-for-openai-after-ceo-sam-altmans-ouster-1700439234754.jpg';
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
use Exception;
|
||||
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
|
||||
use LaravelGoogleIndexing;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use App\Notifications\PostWasPublished;
|
||||
|
||||
class PublishIndexPostTask
|
||||
{
|
||||
@@ -35,6 +37,13 @@ public static function handle(int $post_id)
|
||||
|
||||
}
|
||||
|
||||
Notification::route('facebook','default')->notify(new PostWasPublished($post));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
41
app/Notifications/PostWasPublished.php
Normal file
41
app/Notifications/PostWasPublished.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
use NotificationChannels\FacebookPoster\FacebookPosterChannel;
|
||||
use NotificationChannels\FacebookPoster\FacebookPosterPost;
|
||||
|
||||
class PostWasPublished extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected $post;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct($post)
|
||||
{
|
||||
$this->post = $post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return [FacebookPosterChannel::class];
|
||||
}
|
||||
|
||||
|
||||
public function toFacebookPoster($notifiable) {
|
||||
return (new FacebookPosterPost(str_first_sentence($this->post->bites)))->withLink(route('front.post', ['slug' => $this->post->slug, 'category_slug' => $this->post->category->slug]));
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
"jovix/dataforseo-clientv3": "^1.1",
|
||||
"kalnoy/nestedset": "^6.0",
|
||||
"laravel-freelancer-nl/laravel-index-now": "^1.2",
|
||||
"laravel-notification-channels/facebook-poster": "^5.2",
|
||||
"laravel-notification-channels/telegram": "^4.0",
|
||||
"laravel/framework": "^10.10",
|
||||
"laravel/horizon": "^5.21",
|
||||
|
||||
49
composer.lock
generated
49
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a045f603e8f362bc593db2f33ea2b04d",
|
||||
"content-hash": "776af1e07123b90c65fa82b84aec0043",
|
||||
"packages": [
|
||||
{
|
||||
"name": "artesaos/seotools",
|
||||
@@ -2235,6 +2235,53 @@
|
||||
],
|
||||
"time": "2023-02-17T14:44:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel-notification-channels/facebook-poster",
|
||||
"version": "5.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel-notification-channels/facebook-poster.git",
|
||||
"reference": "46507c45d0a4116955f1c32418a523e8b4bd99f9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel-notification-channels/facebook-poster/zipball/46507c45d0a4116955f1c32418a523e8b4bd99f9",
|
||||
"reference": "46507c45d0a4116955f1c32418a523e8b4bd99f9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"illuminate/notifications": "^8.0|^9.0|^10.0",
|
||||
"illuminate/support": "^8.0|^9.0|^10.0",
|
||||
"php": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.3.3",
|
||||
"phpunit/phpunit": "~9.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"NotificationChannels\\FacebookPoster\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ahmed Ashraf",
|
||||
"email": "ahmed29329@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Use notification to create posts on Facebook",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel-notification-channels/facebook-poster/issues",
|
||||
"source": "https://github.com/laravel-notification-channels/facebook-poster/tree/5.2.0"
|
||||
},
|
||||
"time": "2023-02-13T03:49:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel-notification-channels/telegram",
|
||||
"version": "4.0.0",
|
||||
|
||||
@@ -35,4 +35,9 @@
|
||||
'token' => env('TELEGRAM_BOT_TOKEN'),
|
||||
],
|
||||
|
||||
'facebook_poster' => [
|
||||
'page_id' => env('FACEBOOK_PAGE_ID','126935687180121'),
|
||||
'access_token' => env('FACEBOOK_ACCESS_TOKEN','EAAiaTW680cMBO6BVskmw2ZCH0Mq9FwY8wg9YlT0bgDZBHUR4CmNfmoALkxdpZCbRSJ9Opn03NqjhnhYq7owVVIZAdYgK3ZCqpTulNmX5JWDjCRzPZAYzo0c8txmVvZCrR2mMgIHgu8tVau9XadaCHxvtmaQAhyueSD2SwXKGsrXNRtZCeq9JZBJv4EwOZBJmCcI4mopBBFtVrJobu68XZAcCniZByN2tH8O6h28wo1ICmAwZD'),
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
|
|
||||
*/
|
||||
|
||||
Route::get('/notification', [App\Http\Controllers\Tests\TestController::class, 'notification']);
|
||||
|
||||
|
||||
Route::get('/image_gen', [App\Http\Controllers\Tests\TestController::class, 'imageGen']);
|
||||
|
||||
Route::get('/incomplete/post', function (Request $request) {
|
||||
|
||||
Reference in New Issue
Block a user