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
ccfc2989
Commit
ccfc2989
authored
Mar 03, 2018
by
Darron Park
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add view type media-single on Setting Module (to resolve logo uploading issue#474)
parent
5de11460
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
7 deletions
+75
-7
Setting.php
Modules/Setting/Entities/Setting.php
+2
-1
SettingWasCreated.php
Modules/Setting/Events/SettingWasCreated.php
+25
-2
SettingWasUpdated.php
Modules/Setting/Events/SettingWasUpdated.php
+26
-2
EloquentSettingRepository.php
...tting/Repositories/Eloquent/EloquentSettingRepository.php
+12
-2
media-single.blade.php
...Resources/views/admin/fields/plain/media-single.blade.php
+5
-0
media-single.blade.php
...es/views/admin/fields/translatable/media-single.blade.php
+5
-0
No files found.
Modules/Setting/Entities/Setting.php
View file @
ccfc2989
...
...
@@ -4,10 +4,11 @@ namespace Modules\Setting\Entities;
use
Dimsav\Translatable\Translatable
;
use
Illuminate\Database\Eloquent\Model
;
use
Modules\Media\Support\Traits\MediaRelation
;
class
Setting
extends
Model
{
use
Translatable
;
use
Translatable
,
MediaRelation
;
public
$translatedAttributes
=
[
'value'
,
'description'
];
protected
$fillable
=
[
'name'
,
'value'
,
'description'
,
'isTranslatable'
,
'plainValue'
];
...
...
Modules/Setting/Events/SettingWasCreated.php
View file @
ccfc2989
...
...
@@ -2,17 +2,40 @@
namespace
Modules\Setting\Events
;
use
Modules\Media\Contracts\StoringMedia
;
use
Modules\Setting\Entities\Setting
;
class
SettingWasCreated
class
SettingWasCreated
implements
StoringMedia
{
/**
* @var Setting
*/
public
$setting
;
public
function
__construct
(
Setting
$setting
)
/**
* @var array
*/
public
$data
;
public
function
__construct
(
Setting
$setting
,
$data
)
{
$this
->
setting
=
$setting
;
$this
->
data
=
$data
;
}
/**
* @inheritDoc
*/
public
function
getEntity
()
{
return
$this
->
setting
;
}
/**
* @inheritDoc
*/
public
function
getSubmissionData
()
{
return
$this
->
data
;
}
}
Modules/Setting/Events/SettingWasUpdated.php
View file @
ccfc2989
...
...
@@ -2,17 +2,41 @@
namespace
Modules\Setting\Events
;
use
Modules\Media\Contracts\StoringMedia
;
use
Modules\Setting\Entities\Setting
;
class
SettingWasUpdated
class
SettingWasUpdated
implements
StoringMedia
{
/**
* @var Setting
*/
public
$setting
;
public
function
__construct
(
Setting
$setting
)
/**
* @var array
*/
public
$data
;
public
function
__construct
(
Setting
$setting
,
$data
)
{
$this
->
setting
=
$setting
;
$this
->
data
=
$data
;
}
/**
* @inheritDoc
*/
public
function
getEntity
()
{
return
$this
->
setting
;
}
/**
* @inheritDoc
*/
public
function
getSubmissionData
()
{
return
$this
->
data
;
}
}
Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php
View file @
ccfc2989
...
...
@@ -49,6 +49,16 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
$this
->
removeTokenKey
(
$settings
);
foreach
(
$settings
as
$settingName
=>
$settingValues
)
{
// Check if media exists
if
(
in_array
(
$settingName
,
[
'medias_single'
,
'medias_multiple'
]))
{
// Get first key of values (Original settingName)
foreach
(
$settingValues
as
$key
=>
$value
)
{
$normalisedValue
=
[
$settingName
=>
[
$key
=>
$value
]
];
$settingName
=
$key
;
break
;
}
$settingValues
=
$normalisedValue
;
}
if
(
$setting
=
$this
->
findByName
(
$settingName
))
{
$this
->
updateSetting
(
$setting
,
$settingValues
);
continue
;
...
...
@@ -99,7 +109,7 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
$setting
->
save
();
event
(
new
SettingWasCreated
(
$setting
));
event
(
new
SettingWasCreated
(
$setting
,
$settingValues
));
return
$setting
;
}
...
...
@@ -121,7 +131,7 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
}
$setting
->
save
();
event
(
new
SettingWasUpdated
(
$setting
));
event
(
new
SettingWasUpdated
(
$setting
,
$settingValues
));
return
$setting
;
}
...
...
Modules/Setting/Resources/views/admin/fields/plain/media-single.blade.php
0 → 100644
View file @
ccfc2989
@
php
$setting
=
isset
(
$dbSettings
[
$settingName
])
?
$dbSettings
[
$settingName
]
:
null
;
@
endphp
@
mediaSingle
(
$settingName
,
$setting
,
null
,
trans
(
$moduleInfo
[
'description'
]))
Modules/Setting/Resources/views/admin/fields/translatable/media-single.blade.php
0 → 100644
View file @
ccfc2989
@
php
$setting
=
isset
(
$dbSettings
[
$settingName
])
?
$dbSettings
[
$settingName
]
:
null
;
@
endphp
@
mediaSingle
(
$settingName
,
$setting
,
null
,
trans
(
$moduleInfo
[
'description'
]))
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