Example #1
0
 /**
  * Get or set a connection instance for this model
  *
  * Retrieves the database connection for this model with called without any
  * arguments, otherwise it sets a new database connection and returns that one
  * instead.
  *
  * @param    string    Database connection identifier
  * @return   Nerd\DB   Database connection instance
  */
 public static function connection($identifier = null)
 {
     if (static::$connection === null) {
         static::$connection = DB::connection($identifier);
     }
     return static::$connection;
 }
Example #2
0
 /**
  * Inheritable class constructor
  *
  * If no connection has been set on the static class, then set one using the
  * default DB connection by default.
  *
  * @param    string          DB connection identifier
  */
 public function __construct($connection = null)
 {
     if (static::$connection === null) {
         static::$connection = \Nerd\DB::connection($connection);
     }
 }