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
32d3c4b8
Unverified
Commit
32d3c4b8
authored
Dec 01, 2017
by
Viral Solani
Committed by
GitHub
Dec 01, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #54 from bvipul/vs_refactor_pages_module
Vs refactor pages module
parents
09259d9b
e7e74e44
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
123 additions
and
117 deletions
+123
-117
Backend.php
app/Http/Breadcrumbs/Backend/Backend.php
+1
-1
CMS_Page.php
app/Http/Breadcrumbs/Backend/CMS_Page.php
+0
-16
Page.php
app/Http/Breadcrumbs/Backend/Page.php
+16
-0
PagesController.php
app/Http/Controllers/Backend/Pages/PagesController.php
+17
-17
PagesTableController.php
app/Http/Controllers/Backend/Pages/PagesTableController.php
+4
-8
Page.php
app/Models/Page/Page.php
+9
-2
PageAttribute.php
app/Models/Page/Traits/Attribute/PageAttribute.php
+20
-0
PagesRepository.php
app/Repositories/Backend/Pages/PagesRepository.php
+43
-62
access.php
config/access.php
+0
-5
module.php
config/module.php
+7
-0
edit.blade.php
resources/views/backend/pages/edit.blade.php
+2
-2
index.blade.php
resources/views/backend/pages/index.blade.php
+4
-4
No files found.
app/Http/Breadcrumbs/Backend/Backend.php
View file @
32d3c4b8
...
...
@@ -8,7 +8,7 @@ require __DIR__.'/Search.php';
require
__DIR__
.
'/Access/User.php'
;
require
__DIR__
.
'/Access/Role.php'
;
require
__DIR__
.
'/Access/Permission.php'
;
require
__DIR__
.
'/
CMS_
Page.php'
;
require
__DIR__
.
'/Page.php'
;
require
__DIR__
.
'/Email_Template.php'
;
require
__DIR__
.
'/Setting.php'
;
require
__DIR__
.
'/Blog_Category.php'
;
...
...
app/Http/Breadcrumbs/Backend/CMS_Page.php
deleted
100755 → 0
View file @
09259d9b
<?php
Breadcrumbs
::
register
(
'admin.cmspages.index'
,
function
(
$breadcrumbs
)
{
$breadcrumbs
->
parent
(
'admin.dashboard'
);
$breadcrumbs
->
push
(
trans
(
'menus.backend.cmspages.management'
),
route
(
'admin.cmspages.index'
));
});
Breadcrumbs
::
register
(
'admin.cmspages.create'
,
function
(
$breadcrumbs
)
{
$breadcrumbs
->
parent
(
'admin.cmspages.index'
);
$breadcrumbs
->
push
(
trans
(
'menus.backend.cmspages.create'
),
route
(
'admin.cmspages.create'
));
});
Breadcrumbs
::
register
(
'admin.cmspages.edit'
,
function
(
$breadcrumbs
,
$id
)
{
$breadcrumbs
->
parent
(
'admin.cmspages.index'
);
$breadcrumbs
->
push
(
trans
(
'menus.backend.cmspages.edit'
),
route
(
'admin.cmspages.edit'
,
$id
));
});
app/Http/Breadcrumbs/Backend/Page.php
0 → 100644
View file @
32d3c4b8
<?php
Breadcrumbs
::
register
(
'admin.pages.index'
,
function
(
$breadcrumbs
)
{
$breadcrumbs
->
parent
(
'admin.dashboard'
);
$breadcrumbs
->
push
(
trans
(
'menus.backend.pages.management'
),
route
(
'admin.pages.index'
));
});
Breadcrumbs
::
register
(
'admin.pages.create'
,
function
(
$breadcrumbs
)
{
$breadcrumbs
->
parent
(
'admin.pages.index'
);
$breadcrumbs
->
push
(
trans
(
'menus.backend.pages.create'
),
route
(
'admin.pages.create'
));
});
Breadcrumbs
::
register
(
'admin.pages.edit'
,
function
(
$breadcrumbs
,
$id
)
{
$breadcrumbs
->
parent
(
'admin.pages.index'
);
$breadcrumbs
->
push
(
trans
(
'menus.backend.pages.edit'
),
route
(
'admin.pages.edit'
,
$id
));
});
app/Http/Controllers/Backend/Pages/PagesController.php
View file @
32d3c4b8
...
...
@@ -2,15 +2,15 @@
namespace
App\Http\Controllers\Backend\Pages
;
use
App\Models\Page\Page
;
use
App\Http\Controllers\Controller
;
use
App\Repositories\Backend\Pages\PagesRepository
;
use
App\Http\Requests\Backend\Pages\EditPageRequest
;
use
App\Http\Requests\Backend\Pages\StorePageRequest
;
use
App\Http\Requests\Backend\Pages\CreatePageRequest
;
use
App\Http\Requests\Backend\Pages\DeletePageRequest
;
use
App\Http\Requests\Backend\Pages\EditPageRequest
;
use
App\Http\Requests\Backend\Pages\ManagePageRequest
;
use
App\Http\Requests\Backend\Pages\StorePageRequest
;
use
App\Http\Requests\Backend\Pages\UpdatePageRequest
;
use
App\Models\Page\Page
;
use
App\Repositories\Backend\Pages\PagesRepository
;
/**
* Class PagesController.
...
...
@@ -23,7 +23,7 @@ class PagesController extends Controller
protected
$pages
;
/**
* @param PagesRepository $pages
* @param
\App\Repositories\Backend\Pages\
PagesRepository $pages
*/
public
function
__construct
(
PagesRepository
$pages
)
{
...
...
@@ -31,7 +31,7 @@ class PagesController extends Controller
}
/**
* @param ManagePageRequest $request
* @param
\App\Http\Requests\Backend\Pages\
ManagePageRequest $request
*
* @return mixed
*/
...
...
@@ -41,7 +41,7 @@ class PagesController extends Controller
}
/**
* @param CreatePageRequest $request
* @param
\App\Http\Requests\Backend\Pages\
CreatePageRequest $request
*
* @return mixed
*/
...
...
@@ -51,45 +51,45 @@ class PagesController extends Controller
}
/**
* @param StorePageRequest $request
* @param
\App\Http\Requests\Backend\Pages\
StorePageRequest $request
*
* @return mixed
*/
public
function
store
(
StorePageRequest
$request
)
{
$this
->
pages
->
create
(
$request
->
all
(
));
$this
->
pages
->
create
(
$request
->
except
([
'_token'
]
));
return
redirect
()
->
route
(
'admin.pages.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.pages.created'
));
}
/**
* @param
Page
$page
* @param EditPageRequest $request
* @param
\App\Models\Page\Page
$page
* @param
\App\Http\Requests\Backend\Pages\
EditPageRequest $request
*
* @return mixed
*/
public
function
edit
(
Page
$page
,
EditPageRequest
$request
)
{
return
view
(
'backend.pages.edit'
)
->
with
Cmsp
age
(
$page
);
->
with
P
age
(
$page
);
}
/**
* @param
Page
$page
* @param UpdatePageRequest $request
* @param
\App\Models\Page\Page
$page
* @param
\App\Http\Requests\Backend\Pages\
UpdatePageRequest $request
*
* @return mixed
*/
public
function
update
(
Page
$page
,
UpdatePageRequest
$request
)
{
$this
->
pages
->
update
(
$page
,
$request
->
all
(
));
$this
->
pages
->
update
(
$page
,
$request
->
except
([
'_method'
,
'_token'
]
));
return
redirect
()
->
route
(
'admin.pages.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.pages.updated'
));
}
/**
* @param
Page
$page
* @param DeletePageRequest $request
* @param
\App\Models\Page\Page
$page
* @param
\App\Http\Requests\Backend\Pages\
DeletePageRequest $request
*
* @return mixed
*/
...
...
app/Http/Controllers/Backend/Pages/PagesTableController.php
View file @
32d3c4b8
...
...
@@ -2,11 +2,11 @@
namespace
App\Http\Controllers\Backend\Pages
;
use
App\Http\Controllers\Controller
;
use
App\Http\Requests\Backend\Pages\ManagePageRequest
;
use
App\Repositories\Backend\Pages\PagesRepository
;
use
Carbon\Carbon
;
use
App\Http\Controllers\Controller
;
use
Yajra\DataTables\Facades\DataTables
;
use
App\Repositories\Backend\Pages\PagesRepository
;
use
App\Http\Requests\Backend\Pages\ManagePageRequest
;
/**
* Class PagesTableController.
...
...
@@ -36,11 +36,7 @@ class PagesTableController extends Controller
return
Datatables
::
of
(
$this
->
pages
->
getForDataTable
())
->
escapeColumns
([
'title'
])
->
addColumn
(
'status'
,
function
(
$pages
)
{
if
(
$pages
->
status
)
{
return
'<span class="label label-success">Active</span>'
;
}
return
'<span class="label label-danger">Inactive</span>'
;
return
$pages
->
status_label
;
})
->
addColumn
(
'created_at'
,
function
(
$pages
)
{
return
Carbon
::
parse
(
$pages
->
created_at
)
->
toDateString
();
...
...
app/Models/Page/Page.php
View file @
32d3c4b8
...
...
@@ -4,8 +4,8 @@ namespace App\Models\Page;
use
App\Models\BaseModel
;
use
App\Models\ModelTrait
;
use
App\Models\Page\Traits\Attribute\PageAttribute
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
App\Models\Page\Traits\Attribute\PageAttribute
;
class
Page
extends
BaseModel
{
...
...
@@ -22,9 +22,16 @@ class Page extends BaseModel
*/
protected
$table
;
/**
* The guarded field which are not mass assignable.
*
* @var array
*/
protected
$guarded
=
[
'id'
];
public
function
__construct
(
array
$attributes
=
[])
{
parent
::
__construct
(
$attributes
);
$this
->
table
=
config
(
'
access.cms_pages_
table'
);
$this
->
table
=
config
(
'
module.pages.
table'
);
}
}
app/Models/Page/Traits/Attribute/PageAttribute.php
View file @
32d3c4b8
...
...
@@ -17,4 +17,24 @@ trait PageAttribute
'
.
$this
->
getDeleteButtonAttribute
(
'delete-cms-pages'
,
'admin.pages.destroy'
)
.
'
</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/Pages/PagesRepository.php
View file @
32d3c4b8
...
...
@@ -2,13 +2,12 @@
namespace
App\Repositories\Backend\Pages
;
use
App\Models\Page\Page
;
use
App\Exceptions\GeneralException
;
use
App\Repositories\BaseRepository
;
use
App\Events\Backend\Pages\PageCreated
;
use
App\Events\Backend\Pages\PageDeleted
;
use
App\Events\Backend\Pages\PageUpdated
;
use
App\Exceptions\GeneralException
;
use
App\Models\Page\Page
;
use
App\Repositories\BaseRepository
;
use
DB
;
/**
* Class PagesRepository.
...
...
@@ -27,18 +26,18 @@ class PagesRepository extends BaseRepository
{
return
$this
->
query
()
->
select
([
config
(
'
access.pages_
table'
)
.
'.id'
,
config
(
'
access.pages_
table'
)
.
'.title'
,
config
(
'
access.pages_
table'
)
.
'.status'
,
config
(
'
access.pages_
table'
)
.
'.created_at'
,
config
(
'
access.pages_
table'
)
.
'.updated_at'
,
config
(
'
module.pages.
table'
)
.
'.id'
,
config
(
'
module.pages.
table'
)
.
'.title'
,
config
(
'
module.pages.
table'
)
.
'.status'
,
config
(
'
module.pages.
table'
)
.
'.created_at'
,
config
(
'
module.pages.
table'
)
.
'.updated_at'
,
]);
}
/**
* @param array $input
*
* @throws GeneralException
* @throws
\App\Exceptions\
GeneralException
*
* @return bool
*/
...
...
@@ -48,80 +47,62 @@ class PagesRepository extends BaseRepository
throw
new
GeneralException
(
trans
(
'exceptions.backend.pages.already_exists'
));
}
DB
::
transaction
(
function
()
use
(
$input
)
{
$pages
=
self
::
MODEL
;
$pages
=
new
$pages
();
$pages
->
title
=
$input
[
'title'
];
$pages
->
page_slug
=
str_slug
(
$input
[
'title'
]);
$pages
->
description
=
$input
[
'description'
];
$pages
->
cannonical_link
=
$input
[
'cannonical_link'
];
$pages
->
seo_title
=
$input
[
'seo_title'
];
$pages
->
seo_keyword
=
$input
[
'seo_keyword'
];
$pages
->
seo_description
=
$input
[
'seo_description'
];
$pages
->
status
=
(
isset
(
$input
[
'status'
])
&&
$input
[
'status'
]
==
1
)
?
1
:
0
;
$pages
->
created_by
=
access
()
->
user
()
->
id
;
if
(
$pages
->
save
())
{
event
(
new
PageCreated
(
$pages
));
//Making extra fields
$input
[
'page_slug'
]
=
str_slug
(
$input
[
'title'
]);
$input
[
'status'
]
=
isset
(
$input
[
'status'
])
?
1
:
0
;
$input
[
'created_by'
]
=
access
()
->
user
()
->
id
;
if
(
$page
=
Page
::
create
(
$input
)
)
{
event
(
new
PageCreated
(
$page
));
return
true
;
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.pages.create_error'
));
});
}
/**
* @param
Model $permission
* @param $input
* @param
\App\Models\Page\Page $page
* @param
array
$input
*
* @throws GeneralException
* @throws
\App\Exceptions\
GeneralException
*
* return bool
*
@
return bool
*/
public
function
update
(
Model
$page
,
array
$input
)
public
function
update
(
$page
,
array
$input
)
{
if
(
$this
->
query
()
->
where
(
'title'
,
$input
[
'title'
])
->
where
(
'id'
,
'!='
,
$page
->
id
)
->
first
())
{
throw
new
GeneralException
(
trans
(
'exceptions.backend.pages.already_exists'
));
}
$page
->
title
=
$input
[
'title'
];
$page
->
page_slug
=
str_slug
(
$input
[
'title'
]);
$page
->
description
=
$input
[
'description'
];
$page
->
cannonical_link
=
$input
[
'cannonical_link'
];
$page
->
seo_title
=
$input
[
'seo_title'
];
$page
->
seo_keyword
=
$input
[
'seo_keyword'
];
$page
->
seo_description
=
$input
[
'seo_description'
];
$page
->
status
=
(
isset
(
$input
[
'status'
])
&&
$input
[
'status'
]
==
1
)
?
1
:
0
;
$page
->
updated_by
=
access
()
->
user
()
->
id
;
DB
::
transaction
(
function
()
use
(
$page
,
$input
)
{
if
(
$page
->
save
())
{
//Making extra fields
$input
[
'page_slug'
]
=
str_slug
(
$input
[
'title'
]);
$input
[
'status'
]
=
isset
(
$input
[
'status'
])
?
1
:
0
;
$input
[
'updated_by'
]
=
access
()
->
user
()
->
id
;
if
(
$page
->
update
(
$input
)
)
{
event
(
new
PageUpdated
(
$page
));
return
true
;
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.pages.update_error'
));
});
}
/**
* @param
Model
$page
* @param
\App\Models\Page\Page
$page
*
* @throws GeneralException
* @throws
\App\Exceptions\
GeneralException
*
* @return bool
*/
public
function
delete
(
Model
$page
)
public
function
delete
(
$page
)
{
DB
::
transaction
(
function
()
use
(
$page
)
{
if
(
$page
->
delete
())
{
if
(
$page
->
delete
()
)
{
event
(
new
PageDeleted
(
$page
));
return
true
;
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.pages.delete_error'
));
});
}
}
config/access.php
View file @
32d3c4b8
...
...
@@ -60,11 +60,6 @@ return [
*/
'cities_table'
=>
'cities'
,
/*
* cmspages table used to store cmspages
*/
'pages_table'
=>
'pages'
,
/*
* email template placeholders table used to store email template placeholders
*/
...
...
config/module.php
0 → 100644
View file @
32d3c4b8
<?php
return
[
'pages'
=>
[
'table'
=>
'pages'
]
];
\ No newline at end of file
resources/views/backend/pages/edit.blade.php
View file @
32d3c4b8
...
...
@@ -10,7 +10,7 @@
@
endsection
@
section
(
'content'
)
{{
Form
::
model
(
$
cmspage
,
[
'route'
=>
[
'admin.pages.update'
,
$cms
page
],
'class'
=>
'form-horizontal'
,
'role'
=>
'form'
,
'method'
=>
'PATCH'
,
'id'
=>
'edit-role'
])
}}
{{
Form
::
model
(
$
page
,
[
'route'
=>
[
'admin.pages.update'
,
$
page
],
'class'
=>
'form-horizontal'
,
'role'
=>
'form'
,
'method'
=>
'PATCH'
,
'id'
=>
'edit-role'
])
}}
<
div
class
="
box
box
-
success
">
<div class="
box
-
header
with
-
border
">
...
...
@@ -76,7 +76,7 @@
<div class="
col
-
lg
-
10
">
<div class="
control
-
group
">
<label class="
control
control
--
checkbox
">
{{ Form::checkbox('status', 1, (
$
cms
page->status
== 1) ? true : false ) }}
{{ Form::checkbox('status', 1, (
$page->status
== 1) ? true : false ) }}
<div class="
control__indicator
"></div>
</label>
</div>
...
...
resources/views/backend/pages/index.blade.php
View file @
32d3c4b8
...
...
@@ -74,10 +74,10 @@
type: 'post'
},
columns: [
{data: 'title', name: '
{
{config('
access.pages_
table')}}.title'
}
,
{data: 'status', name: '
{
{config('
access.pages_
table')}}.status'
}
,
{data: 'created_at', name: '
{
{config('
access.pages_
table')}}.created_at'
}
,
{data: 'updated_at', name: '
{
{config('
access.pages_
table')}}.updated_at'
}
,
{data: 'title', name: '
{
{config('
module.pages.
table')}}.title'
}
,
{data: 'status', name: '
{
{config('
module.pages.
table')}}.status'
}
,
{data: 'created_at', name: '
{
{config('
module.pages.
table')}}.created_at'
}
,
{data: 'updated_at', name: '
{
{config('
module.pages.
table')}}.updated_at'
}
,
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[3, "
asc
"]],
...
...
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