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
1c60878c
Commit
1c60878c
authored
Apr 19, 2018
by
Darron Park
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Setting Media type test error
parent
6beaaad8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
4 deletions
+14
-4
Setting.php
Modules/Setting/Entities/Setting.php
+6
-0
EloquentSettingRepository.php
...tting/Repositories/Eloquent/EloquentSettingRepository.php
+3
-3
Settings.php
Modules/Setting/Support/Settings.php
+1
-1
BaseSettingTest.php
Modules/Setting/Tests/BaseSettingTest.php
+4
-0
No files found.
Modules/Setting/Entities/Setting.php
View file @
1c60878c
...
...
@@ -13,4 +13,10 @@ class Setting extends Model
public
$translatedAttributes
=
[
'value'
,
'description'
];
protected
$fillable
=
[
'name'
,
'value'
,
'description'
,
'isTranslatable'
,
'plainValue'
];
protected
$table
=
'setting__settings'
;
public
function
hasMedia
()
:
boolean
{
$value
=
json_decode
(
$this
->
plainValue
,
true
);
return
is_array
(
$value
)
&&
isset
(
$value
[
'media_single'
])
&&
$setting
->
files
->
count
();
}
}
Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php
View file @
1c60878c
...
...
@@ -50,10 +50,10 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
foreach
(
$settings
as
$settingName
=>
$settingValues
)
{
// Check if media exists
if
(
in_array
(
$settingName
,
[
'medias_single'
,
'medias_multiple'
])
)
{
if
(
$settingName
==
'medias_single'
)
{
// Get first key of values (Original settingName)
foreach
(
$settingValues
as
$key
=>
$
value
)
{
$normalisedValue
=
[
$settingName
=>
[
$key
=>
$value
]
];
foreach
(
$settingValues
as
$key
=>
$
mediaId
)
{
$normalisedValue
=
[
'media_single'
=>
$mediaId
];
$settingName
=
$key
;
break
;
}
...
...
Modules/Setting/Support/Settings.php
View file @
1c60878c
...
...
@@ -36,7 +36,7 @@ class Settings implements Setting
return
is_null
(
$default
)
?
$defaultFromConfig
:
$default
;
}
if
(
$
media
=
$setting
->
files
()
->
first
())
{
if
(
$
setting
->
hasMedia
()
&&
$media
=
$setting
->
files
->
first
())
{
return
$media
->
path
;
}
...
...
Modules/Setting/Tests/BaseSettingTest.php
View file @
1c60878c
...
...
@@ -78,5 +78,9 @@ abstract class BaseSettingTest extends TestCase
$this
->
artisan
(
'migrate'
,
[
'--database'
=>
'sqlite'
,
]);
$this
->
artisan
(
'migrate'
,
[
'--database'
=>
'sqlite'
,
'--path'
=>
'Modules/Media/Database/Migrations'
,
]);
}
}
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