/** * @return \Illuminate\View\Factory */ public function getView() { if (!isset($this->view)) { $this->view = Container::getInstance()->make('view'); } return $this->view; }
/** * Add a new Artisan command event to the schedule. * * @param string $command * @param array $parameters * @return \Illuminate\Console\Scheduling\Event */ public function command($command, array $parameters = []) { if (class_exists($command)) { $command = Container::getInstance()->make($command)->getName(); } return $this->exec(Application::formatCommandString($command), $parameters); }
function app($make = null, array $parameters = []) { if (null === $make) { return Container::getInstance(); } return Container::getInstance()->make($make, $parameters); }
/** * Get the available container instance. * * @param string $make * @param array $parameters * @return mixed|\Illuminate\Foundation\Application */ function app($make = null, $parameters = []) { if (is_null($make)) { return Container::getInstance(); } return Container::getInstance()->make($make, $parameters); }
/** * Theme constructor. * @param $title * @param $alias */ public function __construct($title, $alias) { $this->alias = $alias; $this->application = Container::getInstance(); $this->setting = $this->application->make('setting'); $this->title = $title; }
/** * @return \Illuminate\Http\Request */ public function getRequest() { if (!isset($this->request)) { $this->request = Container::getInstance()->make('request'); } return $this->request; }
/** * @return \Illuminate\Events\Dispatcher */ public function getEvents() { if (!isset($this->events)) { $this->events = Container::getInstance()->make('events'); } return $this->events; }
/** * @return \Notadd\Setting\Factory */ public function getSetting() { if (!isset($this->setting)) { $this->setting = Container::getInstance()->make('setting'); } return $this->setting; }
/** * Register the application services. * * @return void */ public function register() { $container = \Illuminate\Container\Container::getInstance(); $container->singleton('tckimlik', 'MuratUnal\\TcKimlik\\TcKimlik'); $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('TcKimlik', "MuratUnal\\TcKimlik\\Laravel\\Facade\\TcKimlik"); }
/** * Add a command, resolving through the application. * * @param string $command * * @return \Symfony\Component\Console\Command\Command */ public function resolve($command) { if (is_null($this->container)) { $this->container = Container::getInstance(); } return $this->add($this->container->make($command)); }
/** * Returns the IoC container. * * @return \Illuminate\Container\Container */ public function getContainer() { if (!isset($this->container)) { $this->app = $this->container = \Illuminate\Container\Container::getInstance(); } return $this->container; }
/** * @return \Illuminate\Config\Repository */ public function getConfig() { if (!isset($this->config)) { $this->config = Container::getInstance()->make('config'); } return $this->config; }
/** * @return \Illuminate\Cookie\CookieJar */ public function getCookie() { if (!isset($this->cookie)) { $this->cookie = Container::getInstance()->make('cookie'); } return $this->cookie; }
/** * @return \Illuminate\View\Compilers\BladeCompiler */ public function getBlade() { if (!isset($this->blade)) { $this->blade = Container::getInstance()->make('view')->getEngineResolver()->resolve('blade')->getCompiler(); } return $this->blade; }
/** * @return \Notadd\Theme\Factory */ public function getTheme() { if (!isset($this->theme)) { $this->theme = Container::getInstance()->make('theme'); } return $this->theme; }
/** * @return \Illuminate\Routing\Router */ public function getRouter() { if (!isset($this->router)) { $this->router = Container::getInstance()->make('router'); } return $this->router; }
/** * @return \Notadd\Foundation\Extension\ExtensionManager */ public function getExtension() { if (!isset($this->extension)) { $this->extension = Container::getInstance()->make('extension'); } return $this->extension; }
/** * Creates a rule instance by name * * @param string $ruleName The name of the validation rule like user_email_unique * * @return ValidationRuleInterface * @throws Exception */ public static function create($ruleName) { if (!isset(static::$registry[$ruleName])) { throw new Exception("Rule with name '{$ruleName}' is not registered"); } return Container::getInstance()->make(static::$registry[$ruleName]); }
/** * Helper function for laravel apps. * * @param string $title * @param string $message * @return mixed */ function flash($title = null, $message = null) { $flash = \Illuminate\Container\Container::getInstance()->make(\Fungku\SweetFlasher\FlashMessage::class); if (func_num_args() == 0) { return $flash; } return $flash->info($title, $message); }
/** * @return void */ public function handle() { $namespace = ConfigurationHelper::getDynamicValue('generator.model.defaults.namespace', ['APP_NAME' => rtrim(Container::getInstance()->getNamespace(), '\\')]); if (Config::get('generator.interaction.namespace')) { $namespace = $this->generator->ask('Model Namespace', $namespace); } $this->model->setNamespace($namespace); }
/** * @param null $make * @param array $parameters * * @return mixed|static */ function repo($make = null, $parameters = []) { if (is_null($make)) { return Container::getInstance(); } $repoPath = config('repository.generator.rootNamespace') . 'Repositories\\'; return Container::getInstance()->make($repoPath . $make, $parameters); }
/** * @return void */ public function handle() { $extends = ConfigurationHelper::getDynamicValue('generator.model.defaults.extends', ['APP_NAME' => rtrim(Container::getInstance()->getNamespace(), '\\')]); if (Config::get('generator.interaction.extends')) { $extends = $this->generator->ask('Model Parent Class', $extends); } $this->model->setExtends($extends); }
/** * Add a new Artisan command event to the schedule. * * @param string $command * @param array $parameters * @return \Illuminate\Console\Scheduling\Event */ public function command($command, array $parameters = []) { if (class_exists($command)) { $command = Container::getInstance()->make($command)->getName(); } $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false)); $artisan = defined('ARTISAN_BINARY') ? ProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan'; return $this->exec("{$binary} {$artisan} {$command}", $parameters); }
/** * Instantiate service container if it's not instantiated yet. */ protected static function instantiateServiceContainer() { $container = Container::getInstance(); if (!$container) { $container = new Container(); Container::setInstance($container); } static::$container = $container; }
/** * Get a factory instance. * * @param $factoryClass * @param $definedName * * @return ModelFactoryInstance */ public function get($factoryClass = null, $definedName = 'default') { if (is_string($factoryClass)) { $this->factory = Container::getInstance()->make('Illuminate\\Database\\Eloquent\\Factory'); $instance = $this->factory->of($factoryClass, $definedName); } else { $instance = null; } return new ModelFactoryInstance($instance, $this->transformerService); }
/** * Store the uploaded file on a filesystem disk. * * @param string $path * @param string $name * @param string|null $disk * @return string|false */ public function storeAs($path, $name, $disk = null) { $factory = Container::getInstance()->make(FilesystemFactory::class); $stream = fopen($this->path(), 'r+'); $result = $factory->disk($disk)->put($path = trim($path . '/' . $name, '/'), $stream); if (is_resource($stream)) { fclose($stream); } return $result ? $path : false; }
/** * Execute the console command. * * @return mixed */ public function handle() { $modelname = strtolower($this->argument('model-name')); $prefix = \Config::get('database.connections.mysql.prefix'); $custom_table_name = $this->option('table-name'); $custom_controller = $this->option('custom-controller'); $singular = $this->option('singular'); $tocreate = []; if ($modelname == 'all') { $pretables = json_decode(json_encode(DB::select("show tables")), true); $tables = []; foreach ($pretables as $p) { list($key) = array_keys($p); $tables[] = $p[$key]; } $this->info("List of tables: " . implode($tables, ",")); foreach ($tables as $t) { // Ignore tables with different prefix if ($prefix == '' || str_contains($t, $prefix)) { $t = strtolower(substr($t, strlen($prefix))); $toadd = ['modelname' => str_singular($t), 'tablename' => '']; if (str_plural($toadd['modelname']) != $t) { $toadd['tablename'] = $t; } $tocreate[] = $toadd; } } // Remove options not applicabe for multiples tables $custom_table_name = null; $custom_controller = null; $singular = null; } else { $tocreate = ['modelname' => $modelname, 'tablename' => '']; if ($singular) { $tocreate['tablename'] = strtolower($modelname); } else { if ($custom_table_name) { $tocreate['tablename'] = $custom_table_name; } } $tocreate = [$tocreate]; } foreach ($tocreate as $c) { $generator = new \CrudGenerator\CrudGeneratorService(); $generator->output = $this; $generator->appNamespace = Container::getInstance()->getNamespace(); $generator->modelName = ucfirst($c['modelname']); $generator->tableName = $c['tablename']; $generator->prefix = $prefix; $generator->force = $this->option('force'); $generator->layout = $this->option('master-layout'); $generator->controllerName = ucfirst(strtolower($custom_controller)) ?: str_plural($generator->modelName); $generator->Generate(); } }
public static function createDoctype($doctype, $bindings = []) { $container = Container::getInstance(); $container->bind(Container::class, function () use($container) { return $container; }); collect($bindings)->each(function ($closure, $name) use($container) { $container->bind($name, $closure); }); return new self($container->build($doctype), $container); }
/** * Handle get property. * * @param $key * * @return mixed */ public function __get($key) { $app = Container::getInstance(); if (in_array($key, $this->aliases['app'])) { return $app; } if (array_key_exists($key, $this->aliases)) { return $app[$this->aliases[$key]]; } return $app[str_replace('_', '.', $key)]; }
public function __construct(CrudModel $model, $args = []) { $this->app = Container::getInstance(); $this->model = $model; $this->columns = $this->model->getList()->getColumns(); $this->params = $args; $this->params['buttons'] = $this->model->getList()->getParam('buttons'); $this->params['sort'] = $this->model->getList()->getParam('sort'); if (!isset($this->params['view_type'])) { $this->params['view_type'] = ''; } }