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
30418788
Commit
30418788
authored
Mar 13, 2018
by
cygnet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring of blogs apis
parent
43e1260b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
29 deletions
+48
-29
BlogsController.php
app/Http/Controllers/Api/V1/BlogsController.php
+43
-24
FaqsController.php
app/Http/Controllers/Api/V1/FaqsController.php
+5
-5
No files found.
app/Http/Controllers/Api/V1/BlogsController.php
View file @
30418788
...
...
@@ -23,9 +23,9 @@ class BlogsController extends APIController
}
/**
* Return the
user
s.
* Return the
blog
s.
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\
Json
Response
*/
public
function
index
(
Request
$request
)
{
...
...
@@ -39,9 +39,9 @@ class BlogsController extends APIController
/**
* Return the specified resource.
*
* @param
User $user
* @param
Blog blog
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\
Json
Response
*/
public
function
show
(
Blog
$blog
)
{
...
...
@@ -53,11 +53,12 @@ class BlogsController extends APIController
*
* @param Request $request
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\
Json
Response
*/
public
function
store
(
Request
$request
)
{
$validation
=
$this
->
validatingRequest
(
$request
);
$validation
=
$this
->
validateBlog
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
...
...
@@ -68,14 +69,16 @@ class BlogsController extends APIController
}
/**
* Update blog
*
* @param Blog $blog
* @param
UpdateBlogRequest
$request
* @param
Request
$request
*
* @return
mixed
* @return
\Illuminate\Http\JsonResponse
*/
public
function
update
(
Request
$request
,
Blog
$blog
)
{
$validation
=
$this
->
validat
ingRequest
(
$request
,
'update'
);
$validation
=
$this
->
validat
eBlog
(
$request
,
'update'
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
...
...
@@ -88,7 +91,31 @@ class BlogsController extends APIController
return
new
BlogsResource
(
$blog
);
}
public
function
validatingRequest
(
Request
$request
,
$type
=
'insert'
)
/**
* Delete Blog
*
* @param Blog $blog
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public
function
destroy
(
Blog
$blog
,
Request
$request
)
{
$this
->
repository
->
delete
(
$blog
);
return
$this
->
respond
([
'message'
=>
trans
(
'alerts.backend.blogs.deleted'
),
]);
}
/**
* validate Blog.
*
* @param $request
*
* @return \Illuminate\Http\JsonResponse
*/
public
function
validateBlog
(
Request
$request
,
$type
=
'insert'
)
{
$featured_image
=
(
$type
==
'insert'
)
?
'required'
:
''
;
...
...
@@ -102,7 +129,11 @@ class BlogsController extends APIController
return
$validation
;
}
/**
* validate message for validate blog.
*
* @return \Illuminate\Http\JsonResponse
*/
public
function
messages
()
{
return
[
...
...
@@ -111,16 +142,4 @@ class BlogsController extends APIController
];
}
/**
* @param Blog $blog
* @param DeleteBlogRequest $request
*
* @return mixed
*/
public
function
destroy
(
Blog
$blog
,
Request
$request
)
{
$this
->
repository
->
delete
(
$blog
);
return
[
'message'
=>
'success'
];
}
}
app/Http/Controllers/Api/V1/FaqsController.php
View file @
30418788
...
...
@@ -25,7 +25,7 @@ class FaqsController extends APIController
/**
* Return the faqs.
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\
Json
Response
*/
public
function
index
(
Request
$request
)
{
...
...
@@ -41,7 +41,7 @@ class FaqsController extends APIController
*
* @param Faq $faq
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\
Json
Response
*/
public
function
show
(
Faq
$faq
)
{
...
...
@@ -53,7 +53,7 @@ class FaqsController extends APIController
*
* @param Request $request
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\
Json
Response
*/
public
function
store
(
Request
$request
)
{
...
...
@@ -73,7 +73,7 @@ class FaqsController extends APIController
* @param Faq $faq
* @param Request $request
*
* @return
mixed
* @return
\Illuminate\Http\JsonResponse
*/
public
function
update
(
Request
$request
,
Faq
$faq
)
{
...
...
@@ -98,7 +98,7 @@ class FaqsController extends APIController
* @param Faq $faq
* @param Request $request
*
* @return
mixed
* @return
\Illuminate\Http\JsonResponse
*/
public
function
destroy
(
Faq
$faq
,
Request
$request
)
{
...
...
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