/**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     CmfDbModel::setDbConnectionConfig(DbConnectionConfig::create()->setDriver(env('DB_CONNECTION', 'pgsql'))->setHost(env('DB_HOST', 'localhost'))->setDbName(env('DB_DATABASE'))->setUserName(env('DB_USERNAME'))->setPassword(env('DB_PASSWORD')));
     DbColumnConfig::registerType('password', DbColumnConfig::DB_TYPE_VARCHAR, PasswordField::class);
     /*if (app()->offsetExists('debugbar') && debugbar()->isEnabled()) {
           $timeCollector = (debugbar()->hasCollector('time')) ? debugbar()->getCollector('time') : null;
           $pdoCollector = new PDOCollector(null, $timeCollector);
           $pdoCollector->setRenderSqlWithParams(true);
           debugbar()->addCollector($pdoCollector);
           Db::setConnectionWrapper(function (Db $db, \PDO $pdo) {
               $pdoTracer = new TraceablePDO($pdo);
               if (debugbar()->hasCollector('pdo')) {
                   debugbar()->getCollector('pdo')->addConnection($pdoTracer, $db->getDbName());
               }
               return $pdoTracer;
           });
       }*/
 }
Exemplo n.º 2
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  * @throws \DebugBar\DebugBarException
  * @throws \PeskyORM\Exception\DbConnectionConfigException
  */
 public function boot()
 {
     $driver = config('database.default');
     CmfDbModel::setDbConnectionConfig(DbConnectionConfig::create()->setDriver($driver)->setHost(config("database.connections.{$driver}.host"))->setDbName(config("database.connections.{$driver}.database"))->setUserName(config("database.connections.{$driver}.username"))->setPassword(config("database.connections.{$driver}.password")));
     DbColumnConfig::registerType('password', DbColumnConfig::DB_TYPE_VARCHAR, PasswordField::class);
     if (config('app.debug', false) && app()->offsetExists('debugbar') && debugbar()->isEnabled()) {
         $timeCollector = debugbar()->hasCollector('time') ? debugbar()->getCollector('time') : null;
         $pdoCollector = new PDOCollector(null, $timeCollector);
         $pdoCollector->setRenderSqlWithParams(true);
         debugbar()->addCollector($pdoCollector);
         Db::setConnectionWrapper(function (Db $db, \PDO $pdo) {
             $pdoTracer = new PeskyOrmPdoTracer($pdo);
             if (debugbar()->hasCollector('pdo')) {
                 debugbar()->getCollector('pdo')->addConnection($pdoTracer, $db->getDbName());
             }
             return $pdoTracer;
         });
     }
 }
Exemplo n.º 3
0
 private function remember_token()
 {
     return DbColumnConfig::create(DbColumnConfig::TYPE_STRING)->setIsRequired(false)->setIsNullable(true)->setConvertEmptyValueToNull(true)->setDefaultValue(null)->setIsPrivate(true);
 }
Exemplo n.º 4
0
 private function is_active()
 {
     return DbColumnConfig::create(DbColumnConfig::TYPE_BOOL)->setIsNullable(false)->setIsRequired(false)->setDefaultValue(true);
 }
Exemplo n.º 5
0
 /**
  * @param InputRendererConfig $rendererConfig
  * @param DbColumnConfig $columnConfig
  * @throws \PeskyORM\Exception\DbColumnConfigException
  */
 protected function configureRendererByColumnConfig(InputRendererConfig $rendererConfig, DbColumnConfig $columnConfig)
 {
     $rendererConfig->setIsRequiredForCreate($columnConfig->isRequiredOn(DbColumnConfig::ON_CREATE))->setIsRequiredForEdit($columnConfig->isRequiredOn(DbColumnConfig::ON_CREATE));
 }
Exemplo n.º 6
0
 public function buildLinkToExternalRecord(DbColumnConfig $columnConfig, array $record, $linkLabel = null)
 {
     if (empty($record[$columnConfig->getName()])) {
         return '-';
     }
     $relationConfig = null;
     $relationAlias = null;
     foreach ($columnConfig->getRelations() as $alias => $relation) {
         if (in_array($relation->getType(), [DbRelationConfig::BELONGS_TO, DbRelationConfig::HAS_ONE])) {
             $relationConfig = $relation;
             $relationAlias = $alias;
             break;
         }
     }
     if (empty($relation)) {
         throw new ScaffoldFieldException($this, "Column [{$columnConfig->getName()}] has no fitting relation");
     }
     if (empty($record[$relationAlias]) || empty($record[$relationAlias][$relationConfig->getDisplayField()])) {
         return CmfConfig::transBase('.item_details.field.no_relation');
     } else {
         return Tag::a(empty($linkLabel) ? $record[$relationAlias][$relationConfig->getDisplayField()] : $linkLabel)->setHref(route('cmf_item_details', [$relationConfig->getForeignTable(), $record[$columnConfig->getName()]]))->build();
     }
 }
Exemplo n.º 7
0
 private function updated_at()
 {
     return DbColumnConfig::create(DbColumnConfig::TYPE_TIMESTAMP)->setIsRequired(false)->setIsNullable(false)->setIsExcluded(true);
 }
Exemplo n.º 8
0
 private function admin_id()
 {
     return DbColumnConfig::create(DbColumnConfig::TYPE_INT)->setIsRequired(false)->setIsNullable(true)->setConvertEmptyValueToNull(true);
 }