Last active
October 4, 2017 21:25
-
-
Save amaelftah/4bb2b4a6f52f13cbcd2fbcbdc07ddfed to your computer and use it in GitHub Desktop.
Real Time Facade
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 | |
use App\Services\ShareService; | |
class Post extends Model | |
{ | |
public function share(ShareService $shareService) | |
{ | |
$shareService->shareOnFacebook($this); | |
} | |
} | |
/******** in Controller for example we will do this *******/ | |
$post = Post::find(1); | |
$service = new ShareService(); | |
$post->share($service); | |
/************************* Using Real Time Facades **********************/ | |
use Facades\App\Services\ShareService; | |
class Post extends Model | |
{ | |
public function share() | |
{ | |
ShareService::shareOnFaceBook($this); | |
} | |
} | |
/******** in Controller *******/ | |
$post = Post::find(1); | |
$post->share(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment