Advertisement
Device-Cheat

service container laravel php main method

Apr 24th, 2020
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. <?php
  2. // app/Service/PostTest.php
  3. namespace App\Service;
  4.  
  5. use App\Post;
  6. use App\Repository\PostRepository;
  7.  
  8. class PostTest
  9. {
  10.     /** @var PostRepository */
  11.     private $repository;
  12.     /** @var SubscriberNotifier */
  13.     private $notifier;
  14.  
  15.     public function __construct(PostRepository $repository, SubscriberNotifier $notifier)
  16.     {
  17.         $this->repository = $repository;
  18.         $this->notifier = $notifier;
  19.     }
  20.  
  21.     public function create(Post $post)
  22.     {
  23.         $this->repository->persist($post);
  24.         $this->notifier->notifyCreate($post);
  25.     }
  26. }
  27.  
  28.  
  29.  
  30.  
  31. //laravel loC
  32. https://github.com/shfx17
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement