/** * Creates a new form for changing the current users avatar. * * @param User $user * * @return \Orchestra\Contracts\Html\Builder */ public function form(User $user) { return $this->form->of('profile.avatar', function (FormGrid $form) use($user) { $form->with($user); $form->attributes(['url' => route('profile.avatar.change'), 'files' => true]); $form->submit = 'Save'; $form->fieldset(function (Fieldset $fieldset) use($user) { if ($user->has_avatar) { $fieldset->control('input:text', 'remove', function ($control) { $control->label = 'Your Current Avatar'; // Generate a field for removing images from the current step. $control->field = function () { // Generate the url of the image. $url = route('profile.avatar.download'); // Generate the HTML image tag $photo = HTML::image($url, null, ['class' => 'img-responsive avatar']); // Return the result as raw HTML. return HTML::raw("<p><div class='col-xs-6 col-sm-4 col-md-2 text-center'>{$photo}</div></p>"); }; }); } $fieldset->control('input:file', 'image')->label($user->has_avatar ? 'Replace Image' : 'Image')->help('Selecting an image will delete your current avatar!'); $fieldset->control('input:checkbox', 'generate')->label('Generate me an Avatar')->help('The generated avatar will be a random color with your initials.')->attributes(['class' => 'switch-mark']); }); }); }
/** * Returns the specified color as an HTML label. * * @param $color * * @return string */ protected static function formatColorLabel($color) { $name = ucfirst($color); // Cast the raw HTML to string before giving it to the // array due to unintentional escaping of it's HTML. return (string) HTML::raw("<span class='label label-{$color}'>{$name}</span>"); }
/** * Returns an HTML string of the users label. * * @return string */ public function label() { $color = 'primary'; $name = HTML::entities($this->user->name); $icon = HTML::create('i', '', ['class' => 'fa fa-user']); return HTML::raw("<span class='label label-{$color}'>{$icon} {$name}</span>"); }
/** * Returns a new form of the guide step. * * @param Guide $guide * @param GuideStep $step * * @return \Orchestra\Contracts\Html\Builder */ public function form(Guide $guide, GuideStep $step) { return $this->form->of('resources.guides.steps', function (FormGrid $form) use($guide, $step) { if ($step->exists) { $method = 'patch'; $url = route('resources.guides.steps.update', [$guide->slug, $step->getPosition()]); $form->submit = 'Save'; } else { $method = 'post'; $url = route('resources.guides.steps.store', [$guide->slug]); $form->submit = 'Create'; } $files = true; $form->attributes(compact('method', 'url', 'files')); $form->with($step); $form->layout('pages.resources.guides.steps._form'); $form->fieldset(function (Fieldset $fieldset) use($guide, $step) { $hasImage = count($step->images) > 0; foreach ($step->images as $image) { $fieldset->control('input:text', 'remove', function ($control) use($guide, $step, $image) { $control->label = 'Image(s)'; // Generate a field for removing images from the current step. $control->field = function () use($guide, $step, $image) { // Generate the url of the image. $url = route('resources.guides.steps.images.download', [$guide->slug, $step->id, $image->uuid]); // Generate the HTML image tag $photo = HTML::image($url, null, ['class' => 'img-responsive']); // Generate the button for deleting the current image. $button = HTML::link(route('resources.guides.steps.images.destroy', [$guide->slug, $step->id, $image->uuid]), 'Delete', ['class' => 'btn btn-danger', 'data-post' => 'DELETE', 'data-title' => 'Delete Image?', 'data-message' => 'Are you sure you want to delete this image?']); // Return the result as raw HTML. return HTML::raw("<div class='col-md-6 text-center'>{$photo} <br> {$button}</div>"); }; }); } $fieldset->control('input:file', 'image')->label($hasImage ? 'Replace Image(s)' : 'Image'); $fieldset->control('input:text', 'title')->attributes(['placeholder' => 'Enter the step title']); $fieldset->control('input:textarea', 'description')->attributes(['placeholder' => 'Enter the step description']); }); }); }
/** * Creates a check mark or x icon depending if * bool is true or false. * * @param bool|false $bool * @param string $text * * @return string */ protected function createCheck($bool = false, $text = '') { if ($bool) { $check = HTML::create('i', '', ['class' => 'fa fa-check']); return HTML::raw("<span class='label label-success'>{$check} {$text}</span>"); } else { $check = HTML::create('i', '', ['class' => 'fa fa-times']); return HTML::raw("<span class='label label-danger'>{$check} {$text}</span>"); } }
/** * Returns an HTML label for the work orders completed at date. * * @return string */ public function getCompletedAtLabel() { if ($this->isComplete()) { $class = 'label label-success'; $icon = 'fa fa-check'; $message = $this->completed_at; } else { $class = 'label label-danger'; $icon = 'fa fa-times'; $message = 'No report has been created.'; } $icon = HTML::create('i', '', ['class' => $icon]); return HTML::raw("<span class='{$class}'>{$icon} {$message}</span>"); }