Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
09fcd83c
Unverified
Commit
09fcd83c
authored
Aug 29, 2018
by
Christian Giupponi
Committed by
GitHub
Aug 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1 from AsgardCms/3.0
merge
parents
92dbe206
62eeb8c1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
macros.php
Modules/Core/macros.php
+45
-0
Page.php
Modules/Page/Entities/Page.php
+11
-0
No files found.
Modules/Core/macros.php
View file @
09fcd83c
...
...
@@ -176,6 +176,32 @@ Form::macro('i18nSelect', function ($name, $title, ViewErrorBag $errors, $lang,
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
...
...
@@ -346,6 +372,25 @@ Form::macro('normalSelect', function ($name, $title, ViewErrorBag $errors, array
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
=
[])
{
return
response
(
$file
,
$status
,
array_merge
([
'Content-Type'
=>
'application/csv'
,
...
...
Modules/Page/Entities/Page.php
View file @
09fcd83c
...
...
@@ -77,4 +77,15 @@ class Page extends Model implements TaggableInterface
#i: No relation found, return the call to parent (Eloquent) to handle it.
return
parent
::
__call
(
$method
,
$parameters
);
}
public
function
getImageAttribute
()
{
$thumbnail
=
$this
->
files
()
->
where
(
'zone'
,
'image'
)
->
first
();
if
(
$thumbnail
===
null
)
{
return
''
;
}
return
$thumbnail
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment