vendredi 5 février 2016

How to use interface in service provider in laravel5

I have interface and two classes which implement this interface

 interface logger
 {
  public function show()
 }

class ToFile implements logger
{
 public function show()
 {
   echo "In file";
 }
}

class ToDatabase implements logger
{
 public function show()
 {
   echo "In InDatabase";
 }
}

Now I have controller where call one of this class at run time depends on condition

class IndexController {
   function index(){
     if($file == true)
      {
        call ToFile  class
      } else {
         call Todatabase class
      }

     }

}

Now my question is How can I use service provider to use these classes in controller Thanks in advance



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1QKhZUU
via IFTTT

Aucun commentaire:

Enregistrer un commentaire