Created
July 24, 2017 11:09
-
-
Save lmichailian/45464806cfaac7a9a5fe2ae4885fb76e to your computer and use it in GitHub Desktop.
complex php
This file contains hidden or 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 | |
class PostController | |
{ | |
public function __construct(PostRepository $postRepository) | |
{ | |
$this->postRepository = $postRepository; | |
} | |
public function index() | |
{ | |
return $this->postRepository()->getAll(); | |
} | |
} | |
interface PostRepository | |
{ | |
public function getAll(); | |
} | |
class EloquentPostRepository implements PostRepository | |
{ | |
public function getAll() | |
{ | |
reutrn Post::all(); | |
} | |
} | |
app()->bind(PostRepository::class, EloquertPostRepository::class); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment