Last active
December 25, 2020 15:50
-
-
Save madi-madi/97eb43a8e9ee0d2a5168edf559f939be to your computer and use it in GitHub Desktop.
PostObserver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Observers; | |
use App\Post; | |
use App\User; | |
use App\Jobs\NewPostJob; | |
use Illuminate\Support\Facades\Notification; | |
use App\Notifications\PushNotification; | |
class PostObserver | |
{ | |
/** | |
* Handle the post "created" event. | |
* | |
* @param \App\Post $post | |
* @return void | |
*/ | |
public function created(Post $post) | |
{ | |
$auth_id = auth()->id(); | |
$users = User::where('id','!=',$auth_id)->get(); | |
Notification::send($users ,new PushNotification($post)); | |
} | |
/** | |
* Handle the post "updated" event. | |
* | |
* @param \App\Post $post | |
* @return void | |
*/ | |
public function updated(Post $post) | |
{ | |
// | |
} | |
/** | |
* Handle the post "deleted" event. | |
* | |
* @param \App\Post $post | |
* @return void | |
*/ | |
public function deleted(Post $post) | |
{ | |
// | |
} | |
/** | |
* Handle the post "restored" event. | |
* | |
* @param \App\Post $post | |
* @return void | |
*/ | |
public function restored(Post $post) | |
{ | |
// | |
} | |
/** | |
* Handle the post "force deleted" event. | |
* | |
* @param \App\Post $post | |
* @return void | |
*/ | |
public function forceDeleted(Post $post) | |
{ | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment