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
61c1c511
Unverified
Commit
61c1c511
authored
Dec 04, 2017
by
Viral Solani
Committed by
GitHub
Dec 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #58 from bvipul/vs_refactor_email_temp_module
Refactored Email Template Module
parents
92c5ecca
4f75d30b
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
94 additions
and
99 deletions
+94
-99
EmailTemplatesController.php
...llers/Backend/EmailTemplates/EmailTemplatesController.php
+12
-20
EmailTemplatesTableController.php
.../Backend/EmailTemplates/EmailTemplatesTableController.php
+3
-7
EmailTemplatePlaceholder.php
...ls/EmailTemplatePlaceholders/EmailTemplatePlaceholder.php
+1
-1
EmailTemplateType.php
app/Models/EmailTemplateTypes/EmailTemplateType.php
+1
-1
EmailTemplate.php
app/Models/EmailTemplates/EmailTemplate.php
+3
-1
EmailTemplateAttribute.php
...mailTemplates/Traits/Attribute/EmailTemplateAttribute.php
+21
-0
EmailTemplatesRepository.php
...ories/Backend/EmailTemplates/EmailTemplatesRepository.php
+23
-30
access.php
config/access.php
+0
-15
module.php
config/module.php
+5
-0
EmailTemplatePlaceholderTableSeeder.php
database/seeds/EmailTemplatePlaceholderTableSeeder.php
+2
-2
EmailTemplateTableSeeder.php
database/seeds/EmailTemplateTableSeeder.php
+2
-2
EmailTemplateTypeTableSeeder.php
database/seeds/EmailTemplateTypeTableSeeder.php
+2
-2
PagesTableSeeder.php
database/seeds/PagesTableSeeder.php
+2
-2
index.blade.php
resources/views/backend/emailtemplates/index.blade.php
+5
-5
Dashboard.php
routes/Backend/Dashboard.php
+0
-11
EmailTemplates.php
routes/Backend/EmailTemplates.php
+12
-0
No files found.
app/Http/Controllers/Backend/EmailTemplates/EmailTemplatesController.php
View file @
61c1c511
...
...
@@ -23,9 +23,9 @@ class EmailTemplatesController extends Controller
protected
$emailtemplates
;
/**
*
Setting the EmailTemplatesRepository instance to class variable.
*
__construct
*
* @param EmailTemplatesRepository $emailtemplates
* @param
\App\Repositories\Backend\EmailTemplates\
EmailTemplatesRepository $emailtemplates
*/
public
function
__construct
(
EmailTemplatesRepository
$emailtemplates
)
{
...
...
@@ -33,9 +33,7 @@ class EmailTemplatesController extends Controller
}
/**
* Use to load index view of EmailTmplates.
*
* @param ManageEmailTemplatesRequest $request
* @param \App\Http\Requests\Backend\EmailTemplates\ManageEmailTemplatesRequest $request
*
* @return mixed
*/
...
...
@@ -45,18 +43,16 @@ class EmailTemplatesController extends Controller
}
/**
* Use to load edit form of Emailtemplate.
*
* @param EmailTemplate $emailtemplate
* @param EditEmailTemplatesRequest $request
* @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* @param \App\Http\Requests\Backend\EmailTemplates\EditEmailTemplatesRequest $request
*
* @return mixed
*/
public
function
edit
(
EmailTemplate
$emailtemplate
,
EditEmailTemplatesRequest
$request
)
{
$emailtemplateTypes
=
EmailTemplateType
::
pluck
(
'name'
,
'id'
);
$emailtemplatePlaceholders
=
EmailTemplatePlaceholder
::
pluck
(
'name'
,
'id'
);
$emailtemplateTypes
=
EmailTemplateType
::
getSelectData
(
);
$emailtemplatePlaceholders
=
EmailTemplatePlaceholder
::
getSelectData
(
);
return
view
(
'backend.emailtemplates.edit'
)
->
withEmailtemplate
(
$emailtemplate
)
...
...
@@ -65,27 +61,23 @@ class EmailTemplatesController extends Controller
}
/**
* Use to update an Emailtemplate.
*
* @param EmailTemplate $emailtemplate
* @param UpdateEmailTemplatesRequest $request
* @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* @param \App\Http\Requests\Backend\EmailTemplates\UpdateEmailTemplatesRequest $request
*
* @return mixed
*/
public
function
update
(
EmailTemplate
$emailtemplate
,
UpdateEmailTemplatesRequest
$request
)
{
$this
->
emailtemplates
->
update
(
$emailtemplate
,
$request
->
all
(
));
$this
->
emailtemplates
->
update
(
$emailtemplate
,
$request
->
except
([
'_method'
,
'_token'
,
'placeholder'
]
));
return
redirect
()
->
route
(
'admin.emailtemplates.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.emailtemplates.updated'
));
}
/**
* Use to delete an Emailtemplate.
*
* @param EmailTemplate $emailtemplate
* @param DeleteEmailTemplatesRequest $request
* @param \App\Models\EmailTemplates\EmailTemplate $emailtemplate
* @param \App\Http\Requests\Backend\EmailTemplates\DeleteEmailTemplatesRequest $request
*
* @return mixed
*/
...
...
app/Http/Controllers/Backend/EmailTemplates/EmailTemplatesTableController.php
View file @
61c1c511
...
...
@@ -19,7 +19,7 @@ class EmailTemplatesTableController extends Controller
protected
$emailtemplates
;
/**
* @param EmailTemplatesRepository $emailtemplates
* @param
\App\Repositories\Backend\EmailTemplates\
EmailTemplatesRepository $emailtemplates
*/
public
function
__construct
(
EmailTemplatesRepository
$emailtemplates
)
{
...
...
@@ -27,7 +27,7 @@ class EmailTemplatesTableController extends Controller
}
/**
* @param ManageEmailTemplatesRequest $request
* @param
\App\Http\Requests\Backend\EmailTemplates\
ManageEmailTemplatesRequest $request
*
* @return mixed
*/
...
...
@@ -36,11 +36,7 @@ class EmailTemplatesTableController extends Controller
return
Datatables
::
of
(
$this
->
emailtemplates
->
getForDataTable
())
->
escapeColumns
([
'title'
])
->
addColumn
(
'status'
,
function
(
$emailtemplates
)
{
if
(
$emailtemplates
->
status
)
{
return
'<span class="label label-success">Active</span>'
;
}
return
'<span class="label label-danger">Inactive</span>'
;
return
$emailtemplates
->
status_label
;
})
->
addColumn
(
'created_at'
,
function
(
$emailtemplates
)
{
return
Carbon
::
parse
(
$emailtemplates
->
created_at
)
->
toDateString
();
...
...
app/Models/EmailTemplatePlaceholders/EmailTemplatePlaceholder.php
View file @
61c1c511
...
...
@@ -16,6 +16,6 @@ class EmailTemplatePlaceholder extends BaseModel
public
function
__construct
(
array
$attributes
=
[])
{
parent
::
__construct
(
$attributes
);
$this
->
table
=
config
(
'
access.email_template_
placeholders_table'
);
$this
->
table
=
config
(
'
module.email_templates.
placeholders_table'
);
}
}
app/Models/EmailTemplateTypes/EmailTemplateType.php
View file @
61c1c511
...
...
@@ -16,6 +16,6 @@ class EmailTemplateType extends BaseModel
public
function
__construct
(
array
$attributes
=
[])
{
parent
::
__construct
(
$attributes
);
$this
->
table
=
config
(
'
access.email_template_
types_table'
);
$this
->
table
=
config
(
'
module.email_templates.
types_table'
);
}
}
app/Models/EmailTemplates/EmailTemplate.php
View file @
61c1c511
...
...
@@ -15,6 +15,8 @@ class EmailTemplate extends BaseModel
// EmailTemplateAttribute::getEditButtonAttribute insteadof ModelTrait;
}
protected
$guarded
=
[
'id'
];
/**
* The database table used by the model.
*
...
...
@@ -25,6 +27,6 @@ class EmailTemplate extends BaseModel
public
function
__construct
(
array
$attributes
=
[])
{
parent
::
__construct
(
$attributes
);
$this
->
table
=
config
(
'
access.email_templates_
table'
);
$this
->
table
=
config
(
'
module.email_templates.
table'
);
}
}
app/Models/EmailTemplates/Traits/Attribute/EmailTemplateAttribute.php
View file @
61c1c511
...
...
@@ -14,4 +14,25 @@ trait EmailTemplateAttribute
{
return
'<div class="btn-group action-btn">'
.
$this
->
getEditButtonAttribute
(
'edit-email-template'
,
'admin.emailtemplates.edit'
)
.
'</div>'
;
}
/**
* @return string
*/
public
function
getStatusLabelAttribute
()
{
if
(
$this
->
isActive
())
{
return
"<label class='label label-success'>"
.
trans
(
'labels.general.active'
)
.
'</label>'
;
}
return
"<label class='label label-danger'>"
.
trans
(
'labels.general.inactive'
)
.
'</label>'
;
}
/**
* @return bool
*/
public
function
isActive
()
{
return
$this
->
status
==
1
;
}
}
app/Repositories/Backend/EmailTemplates/EmailTemplatesRepository.php
View file @
61c1c511
...
...
@@ -26,60 +26,53 @@ class EmailTemplatesRepository extends BaseRepository
{
return
$this
->
query
()
->
select
([
config
(
'
access.email_templates_
table'
)
.
'.id'
,
config
(
'
access.email_templates_
table'
)
.
'.title'
,
config
(
'
access.email_templates_
table'
)
.
'.subject'
,
config
(
'
access.email_templates_
table'
)
.
'.status'
,
config
(
'
access.email_templates_
table'
)
.
'.created_at'
,
config
(
'
access.email_templates_
table'
)
.
'.updated_at'
,
config
(
'
module.email_templates.
table'
)
.
'.id'
,
config
(
'
module.email_templates.
table'
)
.
'.title'
,
config
(
'
module.email_templates.
table'
)
.
'.subject'
,
config
(
'
module.email_templates.
table'
)
.
'.status'
,
config
(
'
module.email_templates.
table'
)
.
'.created_at'
,
config
(
'
module.email_templates.
table'
)
.
'.updated_at'
,
]);
}
/**
* @param
Model $permission
* @param
\App\Models\EmailTemplates\EmailTemplate $emailtemplate
* @param $input
*
* @throws GeneralException
*
* return bool
*/
public
function
update
(
Model
$emailtemplate
,
array
$input
)
public
function
update
(
EmailTemplate
$emailtemplate
,
array
$input
)
{
$emailtemplate
->
title
=
$input
[
'title'
];
$emailtemplate
->
body
=
$input
[
'body'
];
$emailtemplate
->
type_id
=
$input
[
'type_id'
];
$emailtemplate
->
subject
=
$input
[
'subject'
];
$emailtemplate
->
status
=
(
isset
(
$input
[
'is_active'
])
&&
$input
[
'is_active'
]
==
1
)
?
1
:
0
;
$emailtemplate
->
updated_by
=
access
()
->
user
()
->
id
;
$input
[
'status'
]
=
isset
(
$input
[
'is_active'
])
?
1
:
0
;
unset
(
$input
[
'is_active'
]);
$input
[
'updated_by'
]
=
access
()
->
user
()
->
id
;
DB
::
transaction
(
function
()
use
(
$emailtemplate
,
$input
)
{
if
(
$emailtemplate
->
save
())
{
event
(
new
EmailTemplateUpdated
(
$emailtemplate
));
if
(
$emailtemplate
->
update
(
$input
))
{
event
(
new
EmailTemplateUpdated
(
$emailtemplate
));
return
true
;
}
return
true
;
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.emailtemplates.update_error'
));
});
throw
new
GeneralException
(
trans
(
'exceptions.backend.emailtemplates.update_error'
));
}
/**
* @param
Model
$emailtemplate
* @param
\App\Models\EmailTemplates\EmailTemplate
$emailtemplate
*
* @throws GeneralException
*
* @return bool
*/
public
function
delete
(
Model
$emailtemplate
)
public
function
delete
(
EmailTemplate
$emailtemplate
)
{
DB
::
transaction
(
function
()
use
(
$emailtemplate
)
{
if
(
$emailtemplate
->
delete
())
{
event
(
new
EmailTemplateDeleted
(
$emailtemplate
));
if
(
$emailtemplate
->
delete
())
{
event
(
new
EmailTemplateDeleted
(
$emailtemplate
));
return
true
;
}
return
true
;
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.emailtemplates.delete_error'
));
});
throw
new
GeneralException
(
trans
(
'exceptions.backend.emailtemplates.delete_error'
));
}
}
config/access.php
View file @
61c1c511
...
...
@@ -60,21 +60,6 @@ return [
*/
'cities_table'
=>
'cities'
,
/*
* email template placeholders table used to store email template placeholders
*/
'email_template_placeholders_table'
=>
'email_template_placeholders'
,
/*
* email template types table used to store email template types
*/
'email_template_types_table'
=>
'email_template_types'
,
/*
* Email templates table used to store Email templates
*/
'email_templates_table'
=>
'email_templates'
,
/*
* Email templates table used to store Email templates
*/
...
...
config/module.php
View file @
61c1c511
...
...
@@ -4,4 +4,9 @@ return [
'pages'
=>
[
'table'
=>
'pages'
,
],
'email_templates'
=>
[
'table'
=>
'email_templates'
,
'placeholders_table'
=>
'email_template_placeholders'
,
'types_table'
=>
'email_template_types'
]
];
database/seeds/EmailTemplatePlaceholderTableSeeder.php
View file @
61c1c511
...
...
@@ -14,7 +14,7 @@ class EmailTemplatePlaceholderTableSeeder extends Seeder
public
function
run
()
{
if
(
env
(
'DB_CONNECTION'
)
==
'mysql'
)
{
DB
::
table
(
config
(
'
access.email_template_placeholders
_table'
))
->
truncate
();
DB
::
table
(
config
(
'
module.email_templates.placeholder
_table'
))
->
truncate
();
}
$data
=
[
...
...
@@ -75,6 +75,6 @@ class EmailTemplatePlaceholderTableSeeder extends Seeder
],
];
DB
::
table
(
config
(
'
access.email_template_placeholders
_table'
))
->
insert
(
$data
);
DB
::
table
(
config
(
'
module.email_templates.placeholder
_table'
))
->
insert
(
$data
);
}
}
database/seeds/EmailTemplateTableSeeder.php
View file @
61c1c511
...
...
@@ -14,7 +14,7 @@ class EmailTemplateTableSeeder extends Seeder
public
function
run
()
{
if
(
env
(
'DB_CONNECTION'
)
==
'mysql'
)
{
DB
::
table
(
config
(
'
access.email_templates_
table'
))
->
truncate
();
DB
::
table
(
config
(
'
module.email_templates.
table'
))
->
truncate
();
}
$data
=
[
...
...
@@ -285,6 +285,6 @@ class EmailTemplateTableSeeder extends Seeder
],
];
DB
::
table
(
config
(
'
access.email_templates_
table'
))
->
insert
(
$data
);
DB
::
table
(
config
(
'
module.email_templates.
table'
))
->
insert
(
$data
);
}
}
database/seeds/EmailTemplateTypeTableSeeder.php
View file @
61c1c511
...
...
@@ -14,7 +14,7 @@ class EmailTemplateTypeTableSeeder extends Seeder
public
function
run
()
{
if
(
env
(
'DB_CONNECTION'
)
==
'mysql'
)
{
DB
::
table
(
config
(
'
access.email_template_
types_table'
))
->
truncate
();
DB
::
table
(
config
(
'
module.email_templates.
types_table'
))
->
truncate
();
}
$data
=
[
...
...
@@ -43,6 +43,6 @@ class EmailTemplateTypeTableSeeder extends Seeder
],
];
DB
::
table
(
config
(
'
access.email_template_
types_table'
))
->
insert
(
$data
);
DB
::
table
(
config
(
'
module.email_templates.
types_table'
))
->
insert
(
$data
);
}
}
database/seeds/PagesTableSeeder.php
View file @
61c1c511
...
...
@@ -18,7 +18,7 @@ class PagesTableSeeder extends Seeder
public
function
run
()
{
$this
->
disableForeignKeys
();
$this
->
truncate
(
config
(
'
access.pages_
table'
));
$this
->
truncate
(
config
(
'
module.pages.
table'
));
$page
=
[
[
...
...
@@ -32,7 +32,7 @@ class PagesTableSeeder extends Seeder
],
];
DB
::
table
(
config
(
'
access.pages_
table'
))
->
insert
(
$page
);
DB
::
table
(
config
(
'
module.pages.
table'
))
->
insert
(
$page
);
$this
->
enableForeignKeys
();
}
...
...
resources/views/backend/emailtemplates/index.blade.php
View file @
61c1c511
...
...
@@ -92,11 +92,11 @@
type: 'post'
},
columns: [
{data: 'title', name: '
{
{config('
access.email_templates_
table')}}.title'
}
,
{data: 'subject', name: '
{
{config('
access.email_templates_
table')}}.subject'
}
,
{data: 'status', name: '
{
{config('
access.email_templates_
table')}}.status'
}
,
{data: 'created_at', name: '
{
{config('
access.email_templates_
table')}}.created_at'
}
,
{data: 'updated_at', name: '
{
{config('
access.email_templates_
table')}}.updated_at'
}
,
{data: 'title', name: '
{
{config('
module.email_templates.
table')}}.title'
}
,
{data: 'subject', name: '
{
{config('
module.email_templates.
table')}}.subject'
}
,
{data: 'status', name: '
{
{config('
module.email_templates.
table')}}.status'
}
,
{data: 'created_at', name: '
{
{config('
module.email_templates.
table')}}.created_at'
}
,
{data: 'updated_at', name: '
{
{config('
module.email_templates.
table')}}.updated_at'
}
,
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[3, "
asc
"]],
...
...
routes/Backend/Dashboard.php
View file @
61c1c511
...
...
@@ -20,17 +20,6 @@ Route::any('generateSlug', function (\Illuminate\Http\Request $request) {
return
str_slug
(
$request
[
'text'
]);
})
->
name
(
'generate.slug'
);
/*
* Email Templates Management
*/
Route
::
group
([
'namespace'
=>
'EmailTemplates'
],
function
()
{
Route
::
resource
(
'emailtemplates'
,
'EmailTemplatesController'
,
[
'except'
=>
[
'show'
,
'create'
,
'save'
]]);
//For DataTables
Route
::
post
(
'emailtemplates/get'
,
'EmailTemplatesTableController'
)
->
name
(
'emailtemplates.get'
);
});
/*
* Settings Management
*/
...
...
routes/Backend/EmailTemplates.php
0 → 100644
View file @
61c1c511
<?php
/*
* Email Templates Management
*/
Route
::
group
([
'namespace'
=>
'EmailTemplates'
],
function
()
{
Route
::
resource
(
'emailtemplates'
,
'EmailTemplatesController'
,
[
'except'
=>
[
'show'
,
'create'
,
'save'
]]);
//For DataTables
Route
::
post
(
'emailtemplates/get'
,
'EmailTemplatesTableController'
)
->
name
(
'emailtemplates.get'
);
});
\ No newline at end of file
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