public function __construct(DatabaseDriver $db = null) { if (is_null($db)) { $db = Container::fetch('db'); } parent::__construct($db); $this->app = Container::fetch('app'); $ids = $this->app->input->get("cids", null, 'array'); $id = $this->app->input->getInt("id"); if ($id && $id > 0) { $this->id = $id; } elseif (count($ids) == 1) { $this->id = $ids[0]; } else { $this->id = $ids; } }
/** * Instantiate the model. * * @param DatabaseDriver $database The database adapter. * * @since 1.0 */ public function __construct(DatabaseDriver $database) { parent::__construct($database); // Guess the option from the class name (Option)Model(View). if (empty($this->option)) { // Get the fully qualified class name for the current object $fqcn = get_class($this); // Strip the base component namespace off $className = str_replace('App\\', '', $fqcn); // Explode the remaining name into an array $classArray = explode('\\', $className); // Set the option as the first object in this array $this->option = $classArray[0]; } // Set the view name if (empty($this->name)) { $this->getName(); } }
/** * Instantiate the model. * * @param Input $input Input object. * @param DatabaseDriver $db The database adapter. * @param Registry $state The model state. * * @since 1.0 */ public function __construct(Input $input, DatabaseDriver $db, Registry $state = null) { parent::__construct($db); $this->input = $input; }
/** * Instantiate the model. * * @param DatabaseDriver $database The database adapter. * * @since 1.0 */ public function __construct(DatabaseDriver $database = null) { $database = is_null($database) ? Factory::$application->getDatabase() : $database; parent::__construct($database); }