Пример #1
0
 public function register(Application $app)
 {
     $app->set("Database", function ($database = null) use($app) {
         $isDevMode = $app->getConfig('app.settings.environment') == 'development' ?: false;
         $database = $database ?: $app->getConfig('db.default');
         $databaseConfig = $app->getConfig("db.connections.{$database}");
         $doctrineConfig = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/../app/Models"), $isDevMode);
         return EntityManager::create($databaseConfig, $doctrineConfig);
     });
 }
Пример #2
0
 public function register(Application $app)
 {
     $app->set("Filesystem", function ($name = null, $configs = []) use($app) {
         $name = $name ?: $app->getConfig('filesystem.default');
         $filesystemManager = new FilesystemManager($app);
         return $filesystemManager->load($name, $configs);
     });
 }
Пример #3
0
 public function register(Application $app)
 {
     // boot Eloquent
     $defaultConn = $app->getConfig('db.default');
     $capsule = new Capsule();
     $capsule->addConnection($app->getConfig("db.connections.{$defaultConn}"));
     $capsule->setAsGlobal();
     $capsule->bootEloquent();
     $capsule->connection();
     // register Database in container
     $app->set("Database", function ($name = null) use($app) {
         $name = $name ?: $app->getConfig('db.default');
         $config = $app->getConfig("db.connections.{$name}");
         $capsule = new Capsule();
         $capsule->addConnection($config, $name);
         return $capsule->getConnection($name);
     });
 }
Пример #4
0
 public function register(Application $app)
 {
     $app->set("Mail.send", function ($to, $subject, $body, $attachments = array(), $replyTo = "", $from = "", $fromName = "") use($app) {
         $config = $app->getConfig('mail.' . $app->environment);
         $from = !empty($from) ? $from : $config['from'];
         $fromName = !empty($fromName) ? $fromName : $config['fromName'];
         $replyTo = !empty($replyTo) ? $replyTo : $config['replyTo'];
         // Create the SMTP configuration
         $transport = \Swift_SmtpTransport::newInstance($config['server'], $config['port']);
         $transport->setUsername($config['username']);
         $transport->setPassword($config['password']);
         // Create the message
         $message = \Swift_Message::newInstance();
         $message->setTo($to);
         $message->setSubject($subject);
         $message->setBody($body);
         $message->setFrom($from, $fromName);
         $message->addReplyTo($replyTo);
         // Send the email
         $mailer = \Swift_Mailer::newInstance($transport);
         $mailer->send($message);
     });
 }
Пример #5
0
 /**
  * Get the driver configs.
  * @param  string  $name
  * @return string
  */
 private function getDriverConfigs($name)
 {
     //$appMode = $app->environment;
     return $this->app->getConfig("filesystem.connections.{$name}");
 }