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
9fed1f49
Commit
9fed1f49
authored
Dec 29, 2017
by
bvipul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Settings and Page Tests
parent
21af3cb7
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
433 additions
and
253 deletions
+433
-253
SettingsController.php
app/Http/Controllers/Backend/Settings/SettingsController.php
+1
-19
SettingsLogoController.php
...p/Controllers/Backend/Settings/SettingsLogoController.php
+41
-0
BlogsRepository.php
app/Repositories/Backend/Blogs/BlogsRepository.php
+1
-1
SettingsRepository.php
app/Repositories/Backend/Settings/SettingsRepository.php
+56
-54
labels.php
resources/lang/en/labels.php
+1
-1
edit.blade.php
resources/views/backend/settings/edit.blade.php
+249
-177
Settings.php
routes/Backend/Settings.php
+1
-1
ManageSettingsTest.php
tests/Feature/Backend/ManageSettingsTest.php
+83
-0
No files found.
app/Http/Controllers/Backend/Settings/SettingsController.php
View file @
9fed1f49
...
...
@@ -50,22 +50,4 @@ class SettingsController extends Controller
->
route
(
'admin.settings.edit'
,
$setting
->
id
)
->
with
(
'flash_success'
,
trans
(
'alerts.backend.settings.updated'
));
}
/**
* @param Setting $setting
* @param Request $request
* Remove logo or favicon icon
*
* @return mixed
*/
public
function
removeIcon
(
Request
$request
)
{
$this
->
settings
->
removeicon
(
$request
->
data
);
return
json_encode
(
[
'status'
=>
true
,
]
);
}
}
app/Http/Controllers/Backend/Settings/SettingsLogoController.php
0 → 100644
View file @
9fed1f49
<?php
namespace
App\Http\Controllers\Backend\Settings
;
use
App\Http\Controllers\Controller
;
use
App\Models\Settings\Setting
;
use
App\Repositories\Backend\Settings\SettingsRepository
;
use
Illuminate\Http\Request
;
/**
* Class SettingsLogoController.
*/
class
SettingsLogoController
extends
Controller
{
protected
$settings
;
/**
* @param \App\Repositories\Backend\Settings\SettingsRepository $settings
*/
public
function
__construct
(
SettingsRepository
$settings
)
{
$this
->
settings
=
$settings
;
}
/**
* Remove logo or favicon icon
*
* @param \App\Models\Settings\Setting $setting
* @param \Illuminate\Http\Request $request
*
* @return mixed
*/
public
function
destroy
(
Setting
$setting
,
Request
$request
)
{
$this
->
settings
->
removeLogo
(
$setting
,
$request
->
data
);
return
json_encode
([
'status'
=>
true
]);
}
}
app/Repositories/Backend/Blogs/BlogsRepository.php
View file @
9fed1f49
...
...
@@ -132,7 +132,7 @@ class BlogsRepository extends BaseRepository
/**
* Creating Tags.
*
* @param Array
($tags)
* @param Array
$tags
*
* @return array
*/
...
...
app/Repositories/Backend/Settings/SettingsRepository.php
View file @
9fed1f49
...
...
@@ -2,9 +2,10 @@
namespace
App\Repositories\Backend\Settings
;
use
App\Exceptions\GeneralException
;
use
App\Models\Settings\Setting
;
use
App\Exceptions\GeneralException
;
use
App\Repositories\BaseRepository
;
use
Illuminate\Support\Facades\Storage
;
/**
* Class SettingsRepository.
...
...
@@ -16,29 +17,61 @@ class SettingsRepository extends BaseRepository
*/
const
MODEL
=
Setting
::
class
;
/**
* Site Logo Path
*
* @var string
*/
protected
$site_logo_path
;
/**
* Favicon path
*
* @var string
*/
protected
$favicon_path
;
/**
* Storage Class Object
*
* @var \Illuminate\Support\Facades\Storage
*/
protected
$storage
;
/**
* Constructor
*/
public
function
__construct
()
{
$this
->
site_logo_path
=
'img'
.
DIRECTORY_SEPARATOR
.
'logo'
.
DIRECTORY_SEPARATOR
;
$this
->
favicon_path
=
'img'
.
DIRECTORY_SEPARATOR
.
'favicon'
.
DIRECTORY_SEPARATOR
;
$this
->
storage
=
Storage
::
disk
(
'public'
);
}
/**
* @param \App\Models\Settings\Setting $setting
* @param $input
* @param
Array
$input
*
* @throws \App\Exceptions\GeneralException
*
* return bool
*
@
return bool
*/
public
function
update
(
Setting
$setting
,
array
$input
)
{
if
(
isset
(
$input
[
'logo'
]))
{
$image_upload
=
$this
->
uploadlogoimage
(
$setting
,
$input
[
'logo'
]);
$input
[
'logo'
]
=
$image_upload
;
if
(
!
empty
(
$input
[
'logo'
]))
{
$this
->
removeLogo
(
$setting
,
'logo'
);
$input
[
'logo'
]
=
$this
->
uploadLogo
(
$setting
,
$input
[
'logo'
],
'logo'
);
}
if
(
isset
(
$input
[
'favicon'
]))
{
$image_upload
=
$this
->
uploadfaviconimage
(
$setting
,
$input
[
'favicon'
]);
$input
[
'favicon'
]
=
$image_upload
;
if
(
!
empty
(
$input
[
'favicon'
]))
{
$this
->
removeLogo
(
$setting
,
'favicon'
);
$input
[
'favicon'
]
=
$this
->
uploadLogo
(
$setting
,
$input
[
'favicon'
],
'favicon'
);
}
if
(
$setting
->
update
(
$input
))
{
if
(
$setting
->
update
(
$input
))
return
true
;
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.settings.update_error'
));
}
...
...
@@ -46,63 +79,32 @@ class SettingsRepository extends BaseRepository
/*
* Upload logo image
*/
public
function
upload
logoimage
(
$setting
,
$logo
)
public
function
upload
Logo
(
$setting
,
$logo
,
$type
)
{
$
image_name_ex
=
$logo
->
getClientOriginalExtension
()
;
$
path
=
$type
==
"logo"
?
$this
->
site_logo_path
:
$this
->
favicon_path
;
if
(
$setting
->
logo
)
{
if
(
file_exists
(
public_path
()
.
'/img/site_logo/'
.
$setting
->
logo
))
{
unlink
(
'img/site_logo/'
.
$setting
->
logo
);
}
}
$image_name
=
time
()
.
$logo
->
getClientOriginalName
();
$image_name
=
time
()
.
$logo
->
getClientOriginalName
();
$destinationPath
=
public_path
(
'img/site_logo'
);
$logo
->
move
(
$destinationPath
,
$image_name
);
$this
->
storage
->
put
(
$path
.
$image_name
,
file_get_contents
(
$logo
->
getRealPath
()));
return
$image_name
;
}
/*
*
Upload favicon icon image
*
remove logo or favicon icon
*/
public
function
uploadfaviconimage
(
$setting
,
$logo
)
public
function
removeLogo
(
Setting
$setting
,
$type
)
{
$
image_name_ex
=
$logo
->
getClientOriginalExtension
()
;
$
path
=
$type
==
"logo"
?
$this
->
site_logo_path
:
$this
->
favicon_path
;
if
(
$setting
->
favicon
)
{
if
(
file_exists
(
public_path
()
.
'/img/favicon_icon/'
.
$setting
->
favicon
))
{
unlink
(
'img/favicon_icon/'
.
$setting
->
favicon
);
}
if
(
$setting
->
$type
&&
$this
->
storage
->
exists
(
$path
.
$setting
->
$type
))
{
$this
->
storage
->
delete
(
$path
.
$setting
->
$type
);
}
$image_name
=
time
()
.
$logo
->
getClientOriginalName
();
$destinationPath
=
public_path
(
'/img/favicon_icon'
);
$logo
->
move
(
$destinationPath
,
$image_name
);
$result
=
$setting
->
update
([
$type
=>
null
]);
return
$image_name
;
}
if
(
$result
)
return
true
;
/*
* remove logo or favicon icon
*/
public
function
removeicon
(
$input
)
{
$setting
=
$this
->
query
()
->
get
();
if
(
$input
==
'logo'
)
{
if
(
$setting
[
0
]
->
logo
)
{
if
(
file_exists
(
public_path
()
.
'/img/site_logo/'
.
$setting
[
0
]
->
logo
))
{
unlink
(
'img/site_logo/'
.
$setting
[
0
]
->
logo
);
}
$this
->
query
()
->
update
([
'logo'
=>
null
]);
}
}
else
{
if
(
$setting
[
0
]
->
favicon
)
{
if
(
file_exists
(
public_path
()
.
'/img/favicon_icon/'
.
$setting
[
0
]
->
favicon
))
{
unlink
(
'img/favicon_icon/'
.
$setting
[
0
]
->
favicon
);
}
}
$this
->
query
()
->
update
([
'favicon'
=>
null
]);
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.settings.update_error'
));
}
}
resources/lang/en/labels.php
View file @
9fed1f49
...
...
@@ -201,7 +201,7 @@ return [
'companydetails'
=>
'Company Contact Details'
,
'mail'
=>
'Mail Settings'
,
'footer'
=>
'Footer Settings'
,
'terms'
=>
'Terms
&
Condition Settings'
,
'terms'
=>
'Terms
and
Condition Settings'
,
'google'
=>
'Google Analytics Track Code'
,
],
...
...
resources/views/backend/settings/edit.blade.php
View file @
9fed1f49
...
...
@@ -3,167 +3,228 @@
@
section
(
'title'
,
trans
(
'labels.backend.settings.management'
)
.
' | '
.
trans
(
'labels.backend.settings.edit'
))
@
section
(
'page-header'
)
<
h1
>
<
h1
>
{{
trans
(
'labels.backend.settings.management'
)
}}
<
small
>
{{
trans
(
'labels.backend.settings.edit'
)
}}
</
small
>
</
h1
>
</
h1
>
@
endsection
@
section
(
'content'
)
{{
Form
::
model
(
$setting
,
[
'route'
=>
[
'admin.settings.update'
,
$setting
],
'class'
=>
'form-horizontal'
,
'role'
=>
'form'
,
'method'
=>
'PATCH'
,
'files'
=>
true
,
'id'
=>
'edit-role'
])
}}
{{
Form
::
model
(
$setting
,
[
'route'
=>
[
'admin.settings.update'
,
$setting
],
'class'
=>
'form-horizontal'
,
'role'
=>
'form'
,
'method'
=>
'PATCH'
,
'files'
=>
true
,
'id'
=>
'edit-settings'
])
}}
<
div
class
="
box
box
-
info
">
<
div
class
="
box
box
-
info
">
<div class="
box
-
header
">
<h3 class="
box
-
title
">{{ trans('labels.backend.settings.edit') }}</h3>
</div><!-- /.box-header -->
</div>
<!-- /.box-header -->
<div class="
box
-
body
setting
-
block
">
<!-- Nav tabs -->
<ul id="
myTab
" class="
nav
nav
-
tabs
setting
-
tab
-
list
" role="
tablist
">
<li role="
presentation
" class="
active
"><a href="
#tab1" aria-controls="home" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.seo') }}</a></li>
<
li
role
=
"presentation"
><
a
href
=
"#tab2"
aria
-
controls
=
"1"
role
=
"tab"
data
-
toggle
=
"tab"
>
{{
trans
(
'labels.backend.settings.companydetails'
)
}}
</
a
></
li
>
<
li
role
=
"presentation"
><
a
href
=
"#tab3"
aria
-
controls
=
"2"
role
=
"tab"
data
-
toggle
=
"tab"
>
{{
trans
(
'labels.backend.settings.mail'
)
}}
</
a
></
li
>
<
li
role
=
"presentation"
><
a
href
=
"#tab4"
aria
-
controls
=
"3"
role
=
"tab"
data
-
toggle
=
"tab"
>
{{
trans
(
'labels.backend.settings.footer'
)
}}
</
a
></
li
>
<
li
role
=
"presentation"
><
a
href
=
"#tab5"
aria
-
controls
=
"4"
role
=
"tab"
data
-
toggle
=
"tab"
>
{{
trans
(
'labels.backend.settings.terms'
)
}}
</
a
></
li
>
<
li
role
=
"presentation"
><
a
href
=
"#tab6"
aria
-
controls
=
"5"
role
=
"tab"
data
-
toggle
=
"tab"
>
{{
trans
(
'labels.backend.settings.google'
)
}}
</
a
></
li
>
<li role="
presentation
" class="
active
">
<a href="
#tab1" aria-controls="home" role="tab" data-toggle="tab">{{ trans('labels.backend.settings.seo') }}</a>
</
li
>
<
li
role
=
"presentation"
>
<
a
href
=
"#tab2"
aria
-
controls
=
"1"
role
=
"tab"
data
-
toggle
=
"tab"
>
{{
trans
(
'labels.backend.settings.companydetails'
)
}}
</
a
>
</
li
>
<
li
role
=
"presentation"
>
<
a
href
=
"#tab3"
aria
-
controls
=
"2"
role
=
"tab"
data
-
toggle
=
"tab"
>
{{
trans
(
'labels.backend.settings.mail'
)
}}
</
a
>
</
li
>
<
li
role
=
"presentation"
>
<
a
href
=
"#tab4"
aria
-
controls
=
"3"
role
=
"tab"
data
-
toggle
=
"tab"
>
{{
trans
(
'labels.backend.settings.footer'
)
}}
</
a
>
</
li
>
<
li
role
=
"presentation"
>
<
a
href
=
"#tab5"
aria
-
controls
=
"4"
role
=
"tab"
data
-
toggle
=
"tab"
>
{{
trans
(
'labels.backend.settings.terms'
)
}}
</
a
>
</
li
>
<
li
role
=
"presentation"
>
<
a
href
=
"#tab6"
aria
-
controls
=
"5"
role
=
"tab"
data
-
toggle
=
"tab"
>
{{
trans
(
'labels.backend.settings.google'
)
}}
</
a
>
</
li
>
</
ul
>
<!--
Tab
panes
-->
<
div
id
=
"myTabContent"
class
="
tab
-
content
setting
-
tab
">
<div role="
tabpanel
" class="
tab
-
pane
active
" id="
tab1
">
<div class="
form
-
group
">
{{ Form::label('logo', trans('validation.attributes.backend.settings.sitelogo'), ['class' => 'col-lg-2 control-label required
']) }}
{{ Form::label('logo', trans('validation.attributes.backend.settings.sitelogo'), ['class' => 'col-lg-2 control-label
']) }}
<div class="
col
-
lg
-
10
">
<div class="
custom
-
file
-
input
">
{!! Form::file('logo', array('class'=>'form-control inputfile inputfile-1' )) !!}
<label for="
logo
"><i class="
fa
fa
-
upload
"></i><span>Choose a file</span></label>
<label for="
logo
">
<i class="
fa
fa
-
upload
"></i>
<span>Choose a file</span>
</label>
</div>
<div class="
img
-
remove
-
logo
">
@if(
$setting->logo
)
<img height="
50
" width="
50
" src="
{{
url
(
'/img/site_logo/'
)}}
/
{{
$setting
->
logo
}}
">
<img height="
50
" width="
50
" src="
{{
Storage
::
disk
(
'public'
)
->
url
(
'img/site_logo/'
.
$setting
->
logo
)
}}
">
<i id="
remove
-
logo
-
img
" class="
fa
fa
-
times
remove
-
logo
" data-id="
logo
" aria-hidden="
true
"></i>
@endif
</div>
</div><!--col-lg-10-->
</div><!--form control-->
</div>
<!--col-lg-10-->
</div>
<!--form control-->
<div class="
form
-
group
">
{{ Form::label('favicon', trans('validation.attributes.backend.settings.favicon'), ['class' => 'col-lg-2 control-label required']) }}
{{ Form::label('favicon', trans('validation.attributes.backend.settings.favicon'), ['class' => 'col-lg-2 control-label'])
}}
<div class="
col
-
lg
-
10
">
<div class="
custom
-
file
-
input
">
{!! Form::file('favicon', array('class'=>'form-control inputfile inputfile-1' )) !!}
<label for="
favicon
"><i class="
fa
fa
-
upload
"></i><span>Choose a file</span></label>
<label for="
favicon
">
<i class="
fa
fa
-
upload
"></i>
<span>Choose a file</span>
</label>
</div>
<div class="
img
-
remove
-
favicon
">
@if(
$setting->favicon
)
<img height="
50
" width="
50
" src="
{{
url
(
'/img/favicon_icon/'
)}}
/
{{
$setting
->
favicon
}}
">
<img height="
50
" width="
50
" src="
{{
Storage
::
disk
(
'public'
)
->
url
(
'img/favicon/'
.
$setting
->
favicon
)
}}
">
<i id="
remove
-
favicon
-
img
" class="
fa
fa
-
times
remove
-
logo
" data-id="
favicon
" aria-hidden="
true
"></i>
@endif
</div>
</div><!--col-lg-10-->
</div><!--form control-->
</div>
<!--col-lg-10-->
</div>
<!--form control-->
<div class="
form
-
group
">
{{ Form::label('seo_title', trans('validation.attributes.backend.settings.metatitle'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('seo_title', trans('validation.attributes.backend.settings.metatitle'), ['class' => 'col-lg-2 control-label'])
}}
<div class="
col
-
lg
-
10
">
{{ Form::text('seo_title', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metatitle')]) }}
</div><!--col-lg-10-->
</div><!--form control-->
{{ Form::text('seo_title', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metatitle')])
}}
</div>
<!--col-lg-10-->
</div>
<!--form control-->
<div class="
form
-
group
">
{{ Form::label('seo_keyword', trans('validation.attributes.backend.settings.metakeyword'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('seo_keyword', trans('validation.attributes.backend.settings.metakeyword'), ['class' => 'col-lg-2 control-label'])
}}
<div class="
col
-
lg
-
10
">
{{ Form::textarea('seo_keyword', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metakeyword'), 'rows' => 2]) }}
</div><!--col-lg-3-->
</div><!--form control-->
{{ Form::textarea('seo_keyword', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metakeyword'),
'rows' => 2]) }}
</div>
<!--col-lg-3-->
</div>
<!--form control-->
<div class="
form
-
group
">
{{ Form::label('seo_description', trans('validation.attributes.backend.settings.metadescription'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('seo_description', trans('validation.attributes.backend.settings.metadescription'), ['class' => 'col-lg-2
control-label']) }}
<div class="
col
-
lg
-
10
">
{{ Form::textarea('seo_description', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metadescription'), 'rows' => 2]) }}
</div><!--col-lg-3-->
</div><!--form control-->
{{ Form::textarea('seo_description', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.metadescription'),
'rows' => 2]) }}
</div>
<!--col-lg-3-->
</div>
<!--form control-->
</div>
<div role="
tabpanel
" class="
tab
-
pane
" id="
tab2
">
<div class="
form
-
group
">
{{ Form::label('company_address', trans('validation.attributes.backend.settings.companydetails.address'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('company_address', trans('validation.attributes.backend.settings.companydetails.address'), ['class' => 'col-lg-2
control-label']) }}
<div class="
col
-
lg
-
10
">
{{ Form::textarea('company_address', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.address'), 'rows' => 2]) }}
{{ Form::textarea('company_address', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.address'),
'rows' => 2]) }}
</div>
</div>
<div class="
form
-
group
">
{{ Form::label('company_contact', trans('validation.attributes.backend.settings.companydetails.contactnumber'), ['class' => 'col-lg-2 control-label']) }}
<div class="
form
-
group
">
{{ Form::label('company_contact', trans('validation.attributes.backend.settings.companydetails.contactnumber'), ['class'
=> 'col-lg-2 control-label']) }}
<div class="
col
-
lg
-
10
">
{{ Form::text('company_contact', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.contactnumber'), 'rows' => 2]) }}
{{ Form::text('company_contact', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.companydetails.contactnumber'),
'rows' => 2]) }}
</div>
</div>
</div>
<!--form control-->
<!--form control-->
</div>
<div role="
tabpanel
" class="
tab
-
pane
" id="
tab3
">
<div class="
form
-
group
">
{{ Form::label('from_name', trans('validation.attributes.backend.settings.mail.fromname'), ['class' => 'col-lg-2 control-label required']) }}
{{ Form::label('from_name', trans('validation.attributes.backend.settings.mail.fromname'), ['class' => 'col-lg-2 control-label'])
}}
<div class="
col
-
lg
-
10
">
{{ Form::text('from_name', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromname'), 'rows' => 2]) }}
{{ Form::text('from_name', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromname'),
'rows' => 2]) }}
</div>
</div>
<div class="
form
-
group
">
{{ Form::label('from_email', trans('validation.attributes.backend.settings.mail.fromemail'), ['class' => 'col-lg-2 control-label required']) }}
<div class="
form
-
group
">
{{ Form::label('from_email', trans('validation.attributes.backend.settings.mail.fromemail'), ['class' => 'col-lg-2 control-label'])
}}
<div class="
col
-
lg
-
10
">
{{ Form::text('from_email', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromemail'), 'rows' => 2]) }}
{{ Form::text('from_email', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.mail.fromemail'),
'rows' => 2]) }}
</div>
</div>
</div>
<!--form control-->
<!--form control-->
</div>
<div role="
tabpanel
" class="
tab
-
pane
" id="
tab4
">
<div class="
form
-
group
">
{{ Form::label('footer_text', trans('validation.attributes.backend.settings.footer.text'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('footer_text', trans('validation.attributes.backend.settings.footer.text'), ['class' => 'col-lg-2 control-label'])
}}
<div class="
col
-
lg
-
10
">
{{ Form::text('footer_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.text'), 'rows' => 2]) }}
{{ Form::text('footer_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.text'),
'rows' => 2]) }}
</div>
</div>
<div class="
form
-
group
">
{{ Form::label('copyright_text', trans('validation.attributes.backend.settings.footer.copyright'), ['class' => 'col-lg-2 control-label']) }}
<div class="
form
-
group
">
{{ Form::label('copyright_text', trans('validation.attributes.backend.settings.footer.copyright'), ['class' => 'col-lg-2
control-label']) }}
<div class="
col
-
lg
-
10
">
{{ Form::text('copyright_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.copyright'), 'rows' => 2]) }}
{{ Form::text('copyright_text', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.footer.copyright'),
'rows' => 2]) }}
</div>
</div>
</div>
<!--form control-->
<!--form control-->
</div>
<div role="
tabpanel
" class="
tab
-
pane
" id="
tab5
">
<div class="
form
-
group
">
{{ Form::label('terms', trans('validation.attributes.backend.settings.termscondition.terms'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('terms', trans('validation.attributes.backend.settings.termscondition.terms'), ['class' => 'col-lg-2 control-label'])
}}
<div class="
col
-
lg
-
10
">
{{ Form::textarea('terms', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.terms')]) }}
{{ Form::textarea('terms', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.terms')])
}}
</div>
</div>
<div class="
form
-
group
">
{{ Form::label('disclaimer', trans('validation.attributes.backend.settings.termscondition.disclaimer'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('disclaimer', trans('validation.attributes.backend.settings.termscondition.disclaimer'), ['class' => 'col-lg-2
control-label']) }}
<div class="
col
-
lg
-
10
">
{{ Form::textarea('disclaimer', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.disclaimer')]) }}
{{ Form::textarea('disclaimer', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.termscondition.disclaimer')])
}}
</div>
</div><!--form control-->
</div>
<!--form control-->
</div>
<div role="
tabpanel
" class="
tab
-
pane
" id="
tab6
">
<div class="
form
-
group
">
{{ Form::label('google_analytics', trans('validation.attributes.backend.settings.google.analytic'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('google_analytics', trans('validation.attributes.backend.settings.google.analytic'), ['class' => 'col-lg-2
control-label']) }}
<div class="
col
-
lg
-
10
">
{{ Form::textarea('google_analytics', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.google.analytic')]) }}
{{ Form::textarea('google_analytics', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.settings.google.analytic')])
}}
</div>
</div>
<!--form control-->
</div>
</div><!--form control-->
</div>
</div>
</div>
<!-- /.box-body -->
<!-- /.box-body -->
<div class="
box
-
footer
">
<div class="
row
">
<div class="
col
-
lg
-
offset
-
2
col
-
lg
-
10
footer
-
btn
">
...
...
@@ -172,14 +233,24 @@
</div>
</div>
</div>
</div><!--box-->
{{ Form::close() }}
</div><!--box-->
<!-- hidden setting id variable -->
<input type="
hidden
" data-id="
{{
$setting
->
id
}}
" id="
setting
">
{{ Form::close() }}
@endsection
@section('after-scripts')
<script src='/js/backend/bootstrap-tabcollapse.js'></script>
<script>
$('.remove-logo').click(function(){
var data_id = $(this).data('id');
var route = "
{{
route
(
'admin.removeIcon'
,
-
1
)
}}
";
var data_id = $('#setting').data('id');
route = route.replace('-1', data_id);
$('.remove-logo').click(function() {
var data = $(this).data('id');
swal({
title: "
Warning
",
text: "
Are
you
sure
you
want
to
remove
?
",
...
...
@@ -191,7 +262,7 @@
},
function
(
confirmed
)
{
if
(
confirmed
)
{
var
data
=
data_id
;
console
.
log
(
data
)
;
if
(
data
==
'logo'
)
{
value
=
'logo'
;
...
...
@@ -203,7 +274,7 @@
$
(
'.img-remove-favicon'
)
.
addClass
(
'hidden'
);
}
$
.
ajax
({
url
:
"
{
{route('admin.removeicon')}
}
"
,
url
:
route
,
type
:
"POST"
,
data
:
{
data
:
value
},
});
...
...
@@ -215,5 +286,6 @@
tabsClass
:
'hidden-sm hidden-xs'
,
accordionClass
:
'visible-sm visible-xs'
});
</
script
>
@
endsection
\ No newline at end of file
routes/Backend/Settings.php
View file @
9fed1f49
...
...
@@ -6,5 +6,5 @@
Route
::
group
([
'namespace'
=>
'Settings'
],
function
()
{
Route
::
resource
(
'settings'
,
'SettingsController'
,
[
'except'
=>
[
'show'
,
'create'
,
'save'
,
'index'
,
'destroy'
]]);
Route
::
post
(
'removeicon
'
,
'SettingsController@removeIcon'
)
->
name
(
'removei
con'
);
Route
::
post
(
'removeicon
/{setting}'
,
'SettingsLogoController@destroy'
)
->
name
(
'removeI
con'
);
});
tests/Feature/Backend/ManageSettingsTest.php
0 → 100644
View file @
9fed1f49
<?php
namespace
Tests\Feature\Backend
;
use
Tests\TestCase
;
use
App\Models\Settings\Setting
;
use
Illuminate\Http\UploadedFile
;
use
Illuminate\Support\Facades\Storage
;
use
Illuminate\Foundation\Testing\WithFaker
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
class
ManageSettingsTest
extends
TestCase
{
protected
$setting
;
public
function
setUp
()
{
parent
::
setUp
();
$this
->
setting
=
Setting
::
find
(
1
);
$this
->
actingAs
(
$this
->
admin
);
}
/** @test */
public
function
setting_page_shows_different_tabs
()
{
$this
->
get
(
route
(
'admin.settings.edit'
,
$this
->
setting
))
->
assertSee
(
__
(
'labels.backend.settings.seo'
))
->
assertSee
(
__
(
'labels.backend.settings.companydetails'
))
->
assertSee
(
__
(
'labels.backend.settings.mail'
))
->
assertSee
(
__
(
'labels.backend.settings.footer'
))
->
assertSee
(
__
(
'labels.backend.settings.terms'
))
->
assertSee
(
__
(
'labels.backend.settings.google'
));
}
/** @test */
public
function
it_can_update_a_valid_site_logo
()
{
$this
->
patch
(
route
(
'admin.settings.update'
,
$this
->
setting
),
[
'logo'
=>
UploadedFile
::
fake
()
->
image
(
'logo.jpg'
,
226
,
48
)
]);
Storage
::
disk
(
'public'
)
->
assertExists
(
'img/logo/'
.
$this
->
setting
->
logo
);
}
/** @test */
public
function
it_throws_error_for_valid_site_logo
()
{
$this
->
withExceptionHandling
();
$this
->
patch
(
route
(
'admin.settings.update'
,
$this
->
setting
),
[
'logo'
=>
UploadedFile
::
fake
()
->
image
(
'logo.jpg'
,
200
,
500
)
])
->
assertSessionHasErrors
(
'logo'
);
}
/** @test */
public
function
it_can_update_site_favicon
()
{
$this
->
patch
(
route
(
'admin.settings.update'
,
$this
->
setting
),
[
'favicon'
=>
UploadedFile
::
fake
()
->
image
(
'favicon.jpg'
,
16
,
16
)
]);
Storage
::
disk
(
'public'
)
->
assertExists
(
'img/favicon/'
.
$this
->
setting
->
favicon
);
}
/** @test */
public
function
it_throws_error_for_valid_site_favicon
()
{
$this
->
withExceptionHandling
();
$this
->
patch
(
route
(
'admin.settings.update'
,
$this
->
setting
),
[
'favicon'
=>
UploadedFile
::
fake
()
->
image
(
'favicon.jpg'
,
200
,
500
)
])
->
assertSessionHasErrors
(
'favicon'
);
}
/** @test */
public
function
a_user_can_update_settings
()
{
}
}
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