예제 #1
0
 /**
  * Render the dependencies the html for this file.
  * @param array $files
  * @return string
  * @throws \Exception
  */
 public function render($files = [])
 {
     $output = [];
     // Resolve dependencies first.
     foreach ($this->dependencies as $name) {
         if (!array_key_exists($name, $files)) {
             throw new \Exception("Dependency '{$name}' missing for '{$this->name}'");
         }
         $output[] = $files[$name]->render($files);
     }
     if ($this->rendered) {
         return trim(join("\n", $output));
     }
     // Cache busting
     if ($this->src && file_exists(base_path($this->src))) {
         $this->attr[$this->fileSrc[$this->element]] .= "?t=" . filemtime(base_path($this->src));
     }
     $this->rendered = true;
     $output[] = sprintf($this->templates[$this->element], attributize($this->attr));
     return trim(join("\n", $output));
 }
예제 #2
0
 /**
  * Return an image tag of this user.
  * @param null|string $size
  * @param null|string|array $classes
  * @param array $attrs
  * @return string
  */
 public function img($size = null, $classes = null, $attrs = [])
 {
     switch ($size) {
         case "sm":
             $size = 80;
             break;
         case "md":
             $size = 300;
             break;
         case "lg":
             $size = 600;
             break;
         case null:
             $size = 800;
             break;
         default:
             $size = 800;
             break;
     }
     $src = $this->gravatar($size);
     $attr = ['src' => $src, 'class' => $classes, 'alt' => $this->fullName() . " Image"];
     return attributize(array_merge($attr, $attrs), 'img');
 }
예제 #3
0
 /**
  * Return the 'Missing Image' Image.
  * Each model can have it's own 'Missing Image' static var (defined in config file).
  * @param null|string|array $classes
  * @param array $attrs
  * @return string
  */
 public function noImage($classes = null, $attrs = [])
 {
     $missing_image_src = static::blueprint()->no_image;
     if (!$missing_image_src) {
         $missing_image_src = config('media.missing_image');
     }
     $attr = ['alt' => 'Image not found', 'src' => $missing_image_src, 'class' => $classes];
     return attributize(array_merge($attr, $attrs), 'img');
 }
예제 #4
0
 /**
  * Return the image html tag for this object in the given size/crop.
  * Images naturally return the file, other file types may return defaults.
  * @param string $size
  * @param string|array $classes
  * @param array $attrs
  * @return string
  */
 public function img($size = null, $classes = null, $attrs = [])
 {
     $attr = ['src' => $this->urlByType($size), 'class' => is_array($classes) ? join(" ", $classes) : $classes, 'alt' => empty($this->alt_text) ? $this->title : $this->alt_text];
     return attributize(array_merge($attr, $attrs), 'img');
 }
예제 #5
0
 /**
  * Prepare the button to be rendered.
  * @return void|boolean
  */
 public function prepare()
 {
     $user = Auth::user();
     if ($user->cannot('view', $this->parent)) {
         return false;
     }
     $data = $this->toArray();
     $data['attributes'] = attributize($data['attributes']);
     $this->with($data);
 }
예제 #6
0
@if($count)
    @if($element)
        <?php 
echo "<{$element} " . attributize($attributes) . ">";
?>
    @endif

    @foreach($buttons as $btn)

        {!! $btn->render() !!}

    @endforeach

    @if($element)
        <?php 
echo "</{$element}>";
?>
    @endif
@endif