Unverified Commit 09fcd83c authored by Christian Giupponi's avatar Christian Giupponi Committed by GitHub

Merge pull request #1 from AsgardCms/3.0

merge
parents 92dbe206 62eeb8c1
...@@ -176,6 +176,32 @@ Form::macro('i18nSelect', function ($name, $title, ViewErrorBag $errors, $lang, ...@@ -176,6 +176,32 @@ Form::macro('i18nSelect', function ($name, $title, ViewErrorBag $errors, $lang,
return new HtmlString($string); return new HtmlString($string);
}); });
Form::macro('i18nFile', function ($name, $title, ViewErrorBag $errors, $lang, $object = null, array $options = []) {
if (array_key_exists('multiple', $options)) {
$nameForm = "{$lang}[$name][]";
} else {
$nameForm = "{$lang}[$name]";
}
$options = array_merge(['class' => 'form-control'], $options);
$string = "<div class='form-group " . ($errors->has($lang . '.' . $name) ? ' has-error' : '') . "'>";
$string .= "<label for='$nameForm'>$title</label>";
if (is_object($object)) {
$currentData = $object->hasTranslation($lang) ? $object->translate($lang)->{$name} : '';
} else {
$currentData = false;
}
$string .= Form::file("{$lang}[{$name}]",$options);
$string .= $errors->first("{$lang}.{$name}", '<span class="help-block">:message</span>');
$string .= '</div>';
return new HtmlString($string);
});
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Standard fields | Standard fields
...@@ -346,6 +372,25 @@ Form::macro('normalSelect', function ($name, $title, ViewErrorBag $errors, array ...@@ -346,6 +372,25 @@ Form::macro('normalSelect', function ($name, $title, ViewErrorBag $errors, array
return new HtmlString($string); return new HtmlString($string);
}); });
Form::macro('normalFile', function ($name, $title, ViewErrorBag $errors, $object = null, array $options = []) {
$options = array_merge(['class' => 'form-control', 'placeholder' => $title,'multiple'=>'multiple'], $options);
$string = "<div class='form-group " . ($errors->has($name) ? ' has-error' : '') . "'>";
$string .= Form::label($name, $title);
if (is_object($object)) {
$currentData = $object->{$name} ?: '';
} else {
$currentData = null;
}
$string .= Form::file($name,$options);
$string .= $errors->first($name, '<span class="help-block">:message</span>');
$string .= '</div>';
return new HtmlString($string);
});
Response::macro('csv', function ($file, $filename, $status = 200, $headers = []) { Response::macro('csv', function ($file, $filename, $status = 200, $headers = []) {
return response($file, $status, array_merge([ return response($file, $status, array_merge([
'Content-Type' => 'application/csv', 'Content-Type' => 'application/csv',
......
...@@ -77,4 +77,15 @@ class Page extends Model implements TaggableInterface ...@@ -77,4 +77,15 @@ class Page extends Model implements TaggableInterface
#i: No relation found, return the call to parent (Eloquent) to handle it. #i: No relation found, return the call to parent (Eloquent) to handle it.
return parent::__call($method, $parameters); return parent::__call($method, $parameters);
} }
public function getImageAttribute()
{
$thumbnail = $this->files()->where('zone', 'image')->first();
if ($thumbnail === null) {
return '';
}
return $thumbnail;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment