Skip to content

Instantly share code, notes, and snippets.

@amaelftah
Last active October 4, 2017 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amaelftah/4bb2b4a6f52f13cbcd2fbcbdc07ddfed to your computer and use it in GitHub Desktop.
Save amaelftah/4bb2b4a6f52f13cbcd2fbcbdc07ddfed to your computer and use it in GitHub Desktop.
Real Time Facade
<?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