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
5b4fb941
Commit
5b4fb941
authored
Mar 13, 2018
by
cygnet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring the Pages api
parent
9c6b245e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
29 deletions
+56
-29
BlogCategoriesController.php
app/Http/Controllers/Api/V1/BlogCategoriesController.php
+5
-1
PagesController.php
app/Http/Controllers/Api/V1/PagesController.php
+40
-23
PermissionController.php
app/Http/Controllers/Api/V1/PermissionController.php
+4
-0
RolesController.php
app/Http/Controllers/Api/V1/RolesController.php
+3
-1
api.php
routes/api.php
+4
-4
No files found.
app/Http/Controllers/Api/V1/BlogCategoriesController.php
View file @
5b4fb941
...
...
@@ -70,6 +70,8 @@ class BlogCategoriesController extends APIController
}
/**
* Update BlogCategory
*
* @param BlogCategory $blog_category
* @param Request $request
*
...
...
@@ -91,6 +93,8 @@ class BlogCategoriesController extends APIController
}
/**
* Delete BlogCategory
*
* @param BlogCategory $blog_category
* @param Request $request
*
...
...
@@ -106,7 +110,7 @@ class BlogCategoriesController extends APIController
}
/**
* validateUser
Permission
Requests.
* validateUser
BlogCategory
Requests.
*
* @param Request $request
*
...
...
app/Http/Controllers/Api/V1/PagesController.php
View file @
5b4fb941
...
...
@@ -23,9 +23,9 @@ class PagesController extends APIController
}
/**
* Return the
user
s.
* Return the
page
s.
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\
Json
Response
*/
public
function
index
(
Request
$request
)
{
...
...
@@ -39,9 +39,9 @@ class PagesController extends APIController
/**
* Return the specified resource.
*
* @param
User $user
* @param
Pages $page
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\
Json
Response
*/
public
function
show
(
Page
$page
)
{
...
...
@@ -49,15 +49,15 @@ class PagesController extends APIController
}
/**
* Creates the Resour
s
e for Page.
* Creates the Resour
c
e for Page.
*
* @param Request $request
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\
Json
Response
*/
public
function
store
(
Request
$request
)
{
$validation
=
$this
->
validat
ingRequest
(
$request
);
$validation
=
$this
->
validat
ePages
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
...
...
@@ -68,14 +68,16 @@ class PagesController extends APIController
}
/**
* @param Page $page
* @param UpdatePageRequest $request
* Update Page.
*
* @param Page $page
* @param Request $request
*
* @return
mixed
* @return
\Illuminate\Http\JsonResponse
*/
public
function
update
(
Request
$request
,
Page
$page
)
{
$validation
=
$this
->
validat
ingRequest
(
$request
);
$validation
=
$this
->
validat
ePages
(
$request
,
$page
->
id
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
...
...
@@ -88,26 +90,41 @@ class PagesController extends APIController
return
new
PagesResource
(
$page
);
}
public
function
validatingRequest
(
Request
$request
)
{
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'title'
=>
'required|max:191'
,
'description'
=>
'required'
,
]);
return
$validation
;
}
/**
* Delete Page.
*
* @param Page $page
* @param DeletePageRequest $request
*
* @return
mixed
* @return
\Illuminate\Http\JsonResponse
*/
public
function
destroy
(
Page
$page
,
Request
$request
)
{
$this
->
repository
->
delete
(
$page
);
return
[
'message'
=>
'success'
];
return
$this
->
respond
([
'message'
=>
trans
(
'alerts.backend.pages.deleted'
),
]);
}
/**
* validateUser Pages Requests.
*
* @param Request $request
* @param int $id
*
* @return \Illuminate\Http\JsonResponse
*/
public
function
validatePages
(
Request
$request
,
$id
=
0
)
{
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'title'
=>
'required|max:191|unique:pages,title,'
.
$id
,
'description'
=>
'required'
,
]);
return
$validation
;
}
}
app/Http/Controllers/Api/V1/PermissionController.php
View file @
5b4fb941
...
...
@@ -71,6 +71,8 @@ class PermissionController extends APIController
}
/**
* Updates Permission
*
* @param Permission $permission
* @param Request $request
*
...
...
@@ -92,6 +94,8 @@ class PermissionController extends APIController
}
/**
* Delete permission
*
* @param Role $role
* @param DeleteRoleRequest $request
*
...
...
app/Http/Controllers/Api/V1/RolesController.php
View file @
5b4fb941
...
...
@@ -70,7 +70,7 @@ class RolesController extends APIController
}
/**
* Update
User
.
* Update
Role
.
*
* @param Request $request
* @param Role $role
...
...
@@ -93,6 +93,8 @@ class RolesController extends APIController
}
/**
* Delete Role.
*
* @param Role $role
* @param Request $request
*
...
...
routes/api.php
View file @
5b4fb941
...
...
@@ -38,18 +38,18 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
Route
::
resource
(
'permission'
,
'PermissionController'
,
[
'except'
=>
[
'create'
,
'edit'
]]);
// Page
Route
::
resource
(
'pages'
,
'PagesController'
);
Route
::
resource
(
'pages'
,
'PagesController'
,
[
'except'
=>
[
'create'
,
'edit'
]]
);
// Faqs
Route
::
resource
(
'faqs'
,
'FaqsController'
);
Route
::
resource
(
'faqs'
,
'FaqsController'
,
[
'except'
=>
[
'create'
,
'edit'
]]
);
// Blog Categories
Route
::
resource
(
'blog_categories'
,
'BlogCategoriesController'
,
[
'except'
=>
[
'create'
,
'edit'
]]);
// Blog Tags
Route
::
resource
(
'blog_tags'
,
'BlogTagsController'
);
Route
::
resource
(
'blog_tags'
,
'BlogTagsController'
,
[
'except'
=>
[
'create'
,
'edit'
]]
);
// Blogs
Route
::
resource
(
'blogs'
,
'BlogsController'
);
Route
::
resource
(
'blogs'
,
'BlogsController'
,
[
'except'
=>
[
'create'
,
'edit'
]]
);
});
});
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