Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
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
laravel-adminpanel
Commits
0e4788e3
Unverified
Commit
0e4788e3
authored
Dec 11, 2017
by
Viral Solani
Committed by
GitHub
Dec 11, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #81 from bvipul/vs_settings
Refactored Settings
parents
fa36f1e7
344ada51
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
46 deletions
+19
-46
SettingsController.php
app/Http/Controllers/Backend/Settings/SettingsController.php
+9
-10
UpdateSettingsRequest.php
app/Http/Requests/Backend/Settings/UpdateSettingsRequest.php
+3
-23
SettingsRepository.php
app/Repositories/Backend/Settings/SettingsRepository.php
+7
-13
No files found.
app/Http/Controllers/Backend/Settings/SettingsController.php
View file @
0e4788e3
...
@@ -14,13 +14,10 @@ use Illuminate\Http\Request;
...
@@ -14,13 +14,10 @@ use Illuminate\Http\Request;
*/
*/
class
SettingsController
extends
Controller
class
SettingsController
extends
Controller
{
{
/**
* @var SettingsRepository
*/
protected
$settings
;
protected
$settings
;
/**
/**
* @param SettingsRepository $settings
* @param
\App\Repositories\Backend\Settings\
SettingsRepository $settings
*/
*/
public
function
__construct
(
SettingsRepository
$settings
)
public
function
__construct
(
SettingsRepository
$settings
)
{
{
...
@@ -28,8 +25,8 @@ class SettingsController extends Controller
...
@@ -28,8 +25,8 @@ class SettingsController extends Controller
}
}
/**
/**
* @param Setting $setting
* @param
\App\Models\Settings\
Setting $setting
* @param
ManageEmailTemplate
sRequest $request
* @param
\App\Http\Requests\Backend\Settings\ManageSetting
sRequest $request
*
*
* @return mixed
* @return mixed
*/
*/
...
@@ -40,16 +37,18 @@ class SettingsController extends Controller
...
@@ -40,16 +37,18 @@ class SettingsController extends Controller
}
}
/**
/**
* @param Setting $setting
* @param
\App\Models\Settings\
Setting $setting
* @param
UpdateEmailTemplate
sRequest $request
* @param
\App\Http\Requests\Backend\Settings\UpdateSetting
sRequest $request
*
*
* @return mixed
* @return mixed
*/
*/
public
function
update
(
Setting
$setting
,
UpdateSettingsRequest
$request
)
public
function
update
(
Setting
$setting
,
UpdateSettingsRequest
$request
)
{
{
$this
->
settings
->
update
(
$setting
,
$request
->
all
(
));
$this
->
settings
->
update
(
$setting
,
$request
->
except
([
'_token'
,
'_method'
]
));
return
redirect
()
->
route
(
'admin.settings.edit'
,
$setting
->
id
)
->
withFlashSuccess
(
trans
(
'alerts.backend.settings.updated'
));
return
redirect
()
->
route
(
'admin.settings.edit'
,
$setting
->
id
)
->
with
(
'flash_success'
,
trans
(
'alerts.backend.settings.updated'
));
}
}
/**
/**
...
...
app/Http/Requests/Backend/Settings/UpdateSettingsRequest.php
View file @
0e4788e3
...
@@ -27,25 +27,9 @@ class UpdateSettingsRequest extends Request
...
@@ -27,25 +27,9 @@ class UpdateSettingsRequest extends Request
*/
*/
public
function
rules
()
public
function
rules
()
{
{
$data
=
Setting
::
find
(
1
);
$checkLogo
=
$data
->
logo
;
$checkFavicon
=
$data
->
favicon
;
if
(
!
empty
(
$checkLogo
))
{
$logoValidation
=
'image|dimensions:min_width=226,min_height=48'
;
}
else
{
$logoValidation
=
'required|image|dimensions:min_width=226,min_height=48'
;
}
if
(
!
empty
(
$checkFavicon
))
{
$faviconValidation
=
'mimes:jpg,jpeg,png,ico|dimensions:width=16,height=16'
;
}
else
{
$faviconValidation
=
'required|mimes:jpg,jpeg,png,ico|dimensions:width=16,height=16'
;
}
return
[
return
[
'logo'
=>
$logoValidation
,
'logo'
=>
'image|dimensions:min_width=226,min_height=48'
,
'favicon'
=>
$faviconValidation
,
'favicon'
=>
'mimes:jpg,jpeg,png,ico|dimensions:width=16,height=16'
,
'from_name'
=>
'required'
,
'from_email'
=>
'required'
,
];
];
}
}
...
@@ -58,11 +42,7 @@ class UpdateSettingsRequest extends Request
...
@@ -58,11 +42,7 @@ class UpdateSettingsRequest extends Request
{
{
return
[
return
[
'logo.dimensions'
=>
'Invalid logo - should be minimum 226*48'
,
'logo.dimensions'
=>
'Invalid logo - should be minimum 226*48'
,
'favicon.dimensions'
=>
'Invalid icon - should be 16*16'
,
'favicon.dimensions'
=>
'Invalid favicon - should be 16*16'
'logo.required'
=>
'The logo field is required in seo settings.'
,
'favicon.required'
=>
'The favicon field is required in seo settings.'
,
'from_name.required'
=>
'The from name field is required in mail settings.'
,
'from_email.required'
=>
'The from email field is required in mail settings.'
,
];
];
}
}
}
}
app/Repositories/Backend/Settings/SettingsRepository.php
View file @
0e4788e3
...
@@ -18,19 +18,15 @@ class SettingsRepository extends BaseRepository
...
@@ -18,19 +18,15 @@ class SettingsRepository extends BaseRepository
const
MODEL
=
Setting
::
class
;
const
MODEL
=
Setting
::
class
;
/**
/**
* @param
Model $permission
* @param
\App\Models\Settings\Setting $setting
* @param $input
* @param $input
*
*
* @throws GeneralException
* @throws
\App\Exceptions\
GeneralException
*
*
* return bool
* return bool
*/
*/
public
function
update
(
Model
$setting
,
array
$input
)
public
function
update
(
Setting
$setting
,
array
$input
)
{
{
// Unsetting method and token values from array
unset
(
$input
[
'_method'
]);
unset
(
$input
[
'_token'
]);
if
(
isset
(
$input
[
'logo'
]))
{
if
(
isset
(
$input
[
'logo'
]))
{
$image_upload
=
$this
->
uploadlogoimage
(
$setting
,
$input
[
'logo'
]);
$image_upload
=
$this
->
uploadlogoimage
(
$setting
,
$input
[
'logo'
]);
$input
[
'logo'
]
=
$image_upload
;
$input
[
'logo'
]
=
$image_upload
;
...
@@ -41,13 +37,11 @@ class SettingsRepository extends BaseRepository
...
@@ -41,13 +37,11 @@ class SettingsRepository extends BaseRepository
$input
[
'favicon'
]
=
$image_upload
;
$input
[
'favicon'
]
=
$image_upload
;
}
}
DB
::
transaction
(
function
()
use
(
$setting
,
$input
)
{
if
(
$setting
->
update
(
$input
))
{
if
(
$setting
->
update
(
$input
))
{
return
true
;
return
true
;
}
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.settings.update_error'
));
throw
new
GeneralException
(
trans
(
'exceptions.backend.settings.update_error'
));
});
}
}
/*
/*
...
...
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