/** * 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 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']); }); }); }