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
56d571e8
Unverified
Commit
56d571e8
authored
Mar 13, 2018
by
Viral Solani
Committed by
GitHub
Mar 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #175 from indranshastri/develop
Refactoring Blog categroies APIs
parents
820eb477
9c6b245e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
27 deletions
+39
-27
BlogCategoriesController.php
app/Http/Controllers/Api/V1/BlogCategoriesController.php
+31
-20
PermissionController.php
app/Http/Controllers/Api/V1/PermissionController.php
+1
-1
RolesController.php
app/Http/Controllers/Api/V1/RolesController.php
+6
-5
api.php
routes/api.php
+1
-1
No files found.
app/Http/Controllers/Api/V1/BlogCategoriesController.php
View file @
56d571e8
...
...
@@ -23,9 +23,11 @@ class BlogCategoriesController extends APIController
}
/**
* Return the users.
* Return the blog-categories.
*
* @param Request $request
*
*
@return \Illuminate\Http\
Response
*
@return \Illuminate\Http\Json
Response
*/
public
function
index
(
Request
$request
)
{
...
...
@@ -39,9 +41,9 @@ class BlogCategoriesController extends APIController
/**
* Return the specified resource.
*
* @param
User $user
* @param
BlogCategory $blog_category
*
*
@return \Illuminate\Http\
Response
*
@return \Illuminate\Http\Json
Response
*/
public
function
show
(
BlogCategory
$blog_category
)
{
...
...
@@ -53,11 +55,11 @@ class BlogCategoriesController extends APIController
*
* @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
eBlogCategory
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
...
...
@@ -68,14 +70,14 @@ class BlogCategoriesController extends APIController
}
/**
* @param BlogCategory
$blog_category
* @param
UpdateBlogCategoryRequest
$request
* @param BlogCategory $blog_category
* @param
Request
$request
*
* @return mixed
*/
public
function
update
(
Request
$request
,
BlogCategory
$blog_category
)
{
$validation
=
$this
->
validat
ingRequest
(
$request
);
$validation
=
$this
->
validat
eBlogCategory
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
...
...
@@ -88,18 +90,9 @@ class BlogCategoriesController extends APIController
return
new
BlogCategoriesResource
(
$blog_category
);
}
public
function
validatingRequest
(
Request
$request
)
{
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'name'
=>
'required|max:191'
,
]);
return
$validation
;
}
/**
* @param BlogCategory $blog_category
* @param
DeleteBlogCategory
Request $request
* @param Request $request
*
* @return mixed
*/
...
...
@@ -107,6 +100,24 @@ class BlogCategoriesController extends APIController
{
$this
->
repository
->
delete
(
$blog_category
);
return
[
'message'
=>
'success'
];
return
$this
->
respond
([
'message'
=>
trans
(
'alerts.backend.blogcategories.deleted'
),
]);
}
/**
* validateUser Permission Requests.
*
* @param Request $request
*
* @return Validator object
*/
public
function
validateBlogCategory
(
Request
$request
)
{
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'name'
=>
'required|max:191'
,
]);
return
$validation
;
}
}
app/Http/Controllers/Api/V1/PermissionController.php
View file @
56d571e8
...
...
@@ -72,7 +72,7 @@ class PermissionController extends APIController
/**
* @param Permission $permission
* @param
UpdateRoleRequest
$request
* @param
Request
$request
*
* @return \Illuminate\Http\JsonResponse
*/
...
...
app/Http/Controllers/Api/V1/RolesController.php
View file @
56d571e8
...
...
@@ -79,7 +79,7 @@ class RolesController extends APIController
*/
public
function
update
(
Request
$request
,
Role
$role
)
{
$validation
=
$this
->
validateRole
(
$request
);
$validation
=
$this
->
validateRole
(
$request
,
$role
->
id
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
...
...
@@ -110,11 +110,12 @@ class RolesController extends APIController
/**
* validateUser Role Requests.
*
* @param $request
*
* @param Request $request
* @param int $id
*
* @return Validator object
*/
public
function
validateRole
(
Request
$request
)
public
function
validateRole
(
Request
$request
,
$id
=
0
)
{
$permissions
=
''
;
...
...
@@ -123,7 +124,7 @@ class RolesController extends APIController
}
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'name'
=>
'required|max:191
'
,
'name'
=>
'required|max:191
|unique:roles,name,'
.
$id
,
'permissions'
=>
$permissions
,
]);
...
...
routes/api.php
View file @
56d571e8
...
...
@@ -44,7 +44,7 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
Route
::
resource
(
'faqs'
,
'FaqsController'
);
// Blog Categories
Route
::
resource
(
'blog_categories'
,
'BlogCategoriesController'
);
Route
::
resource
(
'blog_categories'
,
'BlogCategoriesController'
,
[
'except'
=>
[
'create'
,
'edit'
]]
);
// Blog Tags
Route
::
resource
(
'blog_tags'
,
'BlogTagsController'
);
...
...
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