Example #1
0
 /**
  * Render the view.
  *
  * @return string
  */
 public function render() : string
 {
     // Get path for the views.
     $path = Router::module()->path() . 'Views/' . $this->file . '.view.php';
     // Render the view.
     return Component::load($path, $this->data);
 }
Example #2
0
 /**
  * Gets a layout.
  *
  * @param  string  $name
  * @param  array   $data
  * @return string
  */
 public static function get(string $name, array $data = []) : string
 {
     // Merge the data.
     static::$data = array_merge_recursive(static::data(), $data);
     // Merge validation errors into the view data.
     if (!isset(static::$data['errors']) && ($errors = Session::flash('validation_errors'))) {
         static::$data['errors'] = $errors;
     }
     // Get the path to the layout.
     $path = path('layouts') . $name . '.layout.php';
     // Load.
     return Component::load($path, static::data());
 }