/** * Execute the console command. * * @return void */ public function fire() { $data = ['table' => $this->argument('table'), 'attachment' => $this->argument('attachment'), 'after' => $this->argument('after')]; // Create filename $file = base_path("database/migrations/" . date('Y_m_d_His') . "_add_{$data['attachment']}_fields_to_{$data['table']}_table.php"); // Save the new migration to disk using the MediaSort migration view. $migration = $this->view->file(realpath(__DIR__ . '/../../resources/views/migration.blade.php'), $data)->render(); $this->file->put($file, $migration); // Print a created migration message to the console. $this->info("Created migration: {$file}"); }
/** * Renders the given template path, and returns the resultant HTTP response. * * @param string $path - The path to the template to be rendered. * @param array $data - The data to pass into the template. * * @return Response */ public function rendered($path, array $data) { // Format path. $path = $this->container->get('settings')['templatePath'] . DIRECTORY_SEPARATOR . $path; $path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path); $path .= '.blade.php'; $response = $this->container['response']; /* @var Response $response */ $response->getBody()->write($this->factory->file($path, $data)->render()); return $response; }
/** * Get the evaluated view contents for the given view. * * @param string $path * @param array $data * @param array $mergeData * @return \Illuminate\View\View * @static */ public static function file($path, $data = array(), $mergeData = array()) { return \Illuminate\View\Factory::file($path, $data, $mergeData); }
protected function buildContent() { $view = $this->view->file(__DIR__ . '/../../../views/content.blade.php'); $view->content = $this->content; return $view; }