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
dfdc6994
Unverified
Commit
dfdc6994
authored
Mar 08, 2018
by
Viral Solani
Committed by
GitHub
Mar 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #154 from indranshastri/develop
Pages Api Changes
parents
1cb96da9
4b1c03f3
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
482 additions
and
12 deletions
+482
-12
BlogCategoriesController.php
app/Http/Controllers/Api/V1/BlogCategoriesController.php
+114
-0
FaqsController.php
app/Http/Controllers/Api/V1/FaqsController.php
+115
-0
PagesController.php
app/Http/Controllers/Api/V1/PagesController.php
+115
-0
PermissionController.php
app/Http/Controllers/Api/V1/PermissionController.php
+4
-4
RolesController.php
app/Http/Controllers/Api/V1/RolesController.php
+3
-3
UsersController.php
app/Http/Controllers/Api/V1/UsersController.php
+35
-4
BlogCategoriesResource.php
app/Http/Resources/BlogCategoriesResource.php
+27
-0
FaqsResource.php
app/Http/Resources/FaqsResource.php
+27
-0
PagesResource.php
app/Http/Resources/PagesResource.php
+28
-0
api.php
routes/api.php
+14
-1
No files found.
app/Http/Controllers/Api/V1/BlogCategoriesController.php
0 → 100755
View file @
dfdc6994
<?php
namespace
App\Http\Controllers\Api\V1
;
use
App\Http\Resources\BlogCategoriesResource
;
use
App\Models\BlogCategories\BlogCategory
;
use
App\Repositories\Backend\BlogCategories\BlogCategoriesRepository
;
use
Illuminate\Http\Request
;
use
Validator
;
class
BlogCategoriesController
extends
APIController
{
protected
$repository
;
/**
* __construct.
*
* @param $repository
*/
public
function
__construct
(
BlogCategoriesRepository
$repository
)
{
$this
->
repository
=
$repository
;
}
/**
* Return the users.
*
* @return \Illuminate\Http\Response
*/
public
function
index
(
Request
$request
)
{
$limit
=
$request
->
get
(
'paginate'
)
?
$request
->
get
(
'paginate'
)
:
25
;
return
BlogCategoriesResource
::
collection
(
$this
->
repository
->
getForDataTable
()
->
paginate
(
$limit
)
);
}
/**
* Return the specified resource.
*
* @param User $user
*
* @return \Illuminate\Http\Response
*/
public
function
show
(
BlogCategory
$blog_category
)
{
return
new
BlogCategoriesResource
(
$blog_category
);
}
/**
* Creates the Resource for BlogCategory.
*
* @param Request $request
*
* @return \Illuminate\Http\Response
*/
public
function
store
(
Request
$request
)
{
$validation
=
$this
->
validatingRequest
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
$this
->
repository
->
create
(
$request
->
all
());
return
new
BlogCategoriesResource
(
BlogCategory
::
orderBy
(
'created_at'
,
'desc'
)
->
first
());
}
/**
* @param BlogCategory $blog_category
* @param UpdateBlogCategoryRequest $request
*
* @return mixed
*/
public
function
update
(
Request
$request
,
BlogCategory
$blog_category
)
{
$validation
=
$this
->
validatingRequest
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
$this
->
repository
->
update
(
$blog_category
,
$request
->
all
());
$blog_category
=
BlogCategory
::
findOrfail
(
$blog_category
->
id
);
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 DeleteBlogCategoryRequest $request
*
* @return mixed
*/
public
function
destroy
(
BlogCategory
$blog_category
,
Request
$request
)
{
$this
->
repository
->
delete
(
$blog_category
);
return
[
'message'
=>
'success'
];
}
}
app/Http/Controllers/Api/V1/FaqsController.php
0 → 100755
View file @
dfdc6994
<?php
namespace
App\Http\Controllers\Api\V1
;
use
App\Http\Resources\FaqsResource
;
use
App\Models\Faqs\Faq
;
use
App\Repositories\Backend\Faqs\FaqsRepository
;
use
Illuminate\Http\Request
;
use
Validator
;
class
FaqsController
extends
APIController
{
protected
$repository
;
/**
* __construct.
*
* @param $repository
*/
public
function
__construct
(
FaqsRepository
$repository
)
{
$this
->
repository
=
$repository
;
}
/**
* Return the users.
*
* @return \Illuminate\Http\Response
*/
public
function
index
(
Request
$request
)
{
$limit
=
$request
->
get
(
'paginate'
)
?
$request
->
get
(
'paginate'
)
:
25
;
return
FaqsResource
::
collection
(
$this
->
repository
->
getForDataTable
()
->
paginate
(
$limit
)
);
}
/**
* Return the specified resource.
*
* @param User $user
*
* @return \Illuminate\Http\Response
*/
public
function
show
(
Faq
$faq
)
{
return
new
FaqsResource
(
$faq
);
}
/**
* Creates the Resource for Faq.
*
* @param Request $request
*
* @return \Illuminate\Http\Response
*/
public
function
store
(
Request
$request
)
{
$validation
=
$this
->
validatingRequest
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
$this
->
repository
->
create
(
$request
->
all
());
return
new
FaqsResource
(
Faq
::
orderBy
(
'created_at'
,
'desc'
)
->
first
());
}
/**
* @param Faq $faq
* @param UpdateFaqRequest $request
*
* @return mixed
*/
public
function
update
(
Request
$request
,
Faq
$faq
)
{
$validation
=
$this
->
validatingRequest
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
$this
->
repository
->
update
(
$faq
,
$request
->
all
());
$faq
=
Faq
::
findOrfail
(
$faq
->
id
);
return
new
FaqsResource
(
$faq
);
}
public
function
validatingRequest
(
Request
$request
)
{
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'question'
=>
'required|max:191'
,
'answer'
=>
'required'
,
]);
return
$validation
;
}
/**
* @param Faq $faq
* @param DeleteFaqRequest $request
*
* @return mixed
*/
public
function
destroy
(
Faq
$faq
,
Request
$request
)
{
$this
->
repository
->
delete
(
$faq
);
return
[
'message'
=>
'success'
];
}
}
app/Http/Controllers/Api/V1/PagesController.php
0 → 100644
View file @
dfdc6994
<?php
namespace
App\Http\Controllers\Api\V1
;
use
App\Http\Resources\PagesResource
;
use
App\Models\Page\Page
;
use
App\Repositories\Backend\Pages\PagesRepository
;
use
Illuminate\Http\Request
;
use
Validator
;
class
PagesController
extends
APIController
{
protected
$repository
;
/**
* __construct.
*
* @param $repository
*/
public
function
__construct
(
PagesRepository
$repository
)
{
$this
->
repository
=
$repository
;
}
/**
* Return the users.
*
* @return \Illuminate\Http\Response
*/
public
function
index
(
Request
$request
)
{
$limit
=
$request
->
get
(
'paginate'
)
?
$request
->
get
(
'paginate'
)
:
25
;
return
PagesResource
::
collection
(
$this
->
repository
->
getForDataTable
()
->
paginate
(
$limit
)
);
}
/**
* Return the specified resource.
*
* @param User $user
*
* @return \Illuminate\Http\Response
*/
public
function
show
(
Page
$page
)
{
return
new
PagesResource
(
$page
);
}
/**
* Creates the Resourse for Page.
*
* @param Request $request
*
* @return \Illuminate\Http\Response
*/
public
function
store
(
Request
$request
)
{
$validation
=
$this
->
validatingRequest
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
$this
->
repository
->
create
(
$request
->
all
());
return
new
PagesResource
(
Page
::
orderBy
(
'created_at'
,
'desc'
)
->
first
());
}
/**
* @param Page $page
* @param UpdatePageRequest $request
*
* @return mixed
*/
public
function
update
(
Request
$request
,
Page
$page
)
{
$validation
=
$this
->
validatingRequest
(
$request
);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
$this
->
repository
->
update
(
$page
,
$request
->
all
());
$page
=
Page
::
findOrfail
(
$page
->
id
);
return
new
PagesResource
(
$page
);
}
public
function
validatingRequest
(
Request
$request
)
{
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'title'
=>
'required|max:191'
,
'description'
=>
'required'
,
]);
return
$validation
;
}
/**
* @param Page $page
* @param DeletePageRequest $request
*
* @return mixed
*/
public
function
destroy
(
Page
$page
,
Request
$request
)
{
$this
->
repository
->
delete
(
$page
);
return
[
'message'
=>
'success'
];
}
}
app/Http/Controllers/Api/V1/PermissionController.php
View file @
dfdc6994
...
@@ -49,7 +49,7 @@ class PermissionController extends APIController
...
@@ -49,7 +49,7 @@ class PermissionController extends APIController
}
}
/**
/**
* Creates the Resour
s
e for Role.
* Creates the Resour
c
e for Role.
*
*
* @param Request $request
* @param Request $request
*
*
...
@@ -57,7 +57,7 @@ class PermissionController extends APIController
...
@@ -57,7 +57,7 @@ class PermissionController extends APIController
*/
*/
public
function
store
(
Request
$request
)
public
function
store
(
Request
$request
)
{
{
$validation
=
$this
->
valiatingRequest
(
$request
);
$validation
=
$this
->
vali
d
atingRequest
(
$request
);
if
(
$validation
->
fails
())
{
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
}
...
@@ -76,7 +76,7 @@ class PermissionController extends APIController
...
@@ -76,7 +76,7 @@ class PermissionController extends APIController
*/
*/
public
function
update
(
Request
$request
,
Permission
$permission
)
public
function
update
(
Request
$request
,
Permission
$permission
)
{
{
$validation
=
$this
->
valiatingRequest
(
$request
);
$validation
=
$this
->
vali
d
atingRequest
(
$request
);
if
(
$validation
->
fails
())
{
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
...
@@ -89,7 +89,7 @@ class PermissionController extends APIController
...
@@ -89,7 +89,7 @@ class PermissionController extends APIController
return
new
PermissionResource
(
$permission
);
return
new
PermissionResource
(
$permission
);
}
}
public
function
valiatingRequest
(
Request
$request
)
public
function
vali
d
atingRequest
(
Request
$request
)
{
{
$validation
=
Validator
::
make
(
$request
->
all
(),
[
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'name'
=>
'required|max:191'
,
'name'
=>
'required|max:191'
,
...
...
app/Http/Controllers/Api/V1/RolesController.php
View file @
dfdc6994
...
@@ -57,7 +57,7 @@ class RolesController extends APIController
...
@@ -57,7 +57,7 @@ class RolesController extends APIController
*/
*/
public
function
store
(
Request
$request
)
public
function
store
(
Request
$request
)
{
{
$validation
=
$this
->
valiatingRequest
(
$request
);
$validation
=
$this
->
vali
d
atingRequest
(
$request
);
if
(
$validation
->
fails
())
{
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
}
...
@@ -75,7 +75,7 @@ class RolesController extends APIController
...
@@ -75,7 +75,7 @@ class RolesController extends APIController
*/
*/
public
function
update
(
Request
$request
,
Role
$role
)
public
function
update
(
Request
$request
,
Role
$role
)
{
{
$validation
=
$this
->
valiatingRequest
(
$request
);
$validation
=
$this
->
vali
d
atingRequest
(
$request
);
if
(
$validation
->
fails
())
{
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
...
@@ -88,7 +88,7 @@ class RolesController extends APIController
...
@@ -88,7 +88,7 @@ class RolesController extends APIController
return
new
RoleResource
(
$role
);
return
new
RoleResource
(
$role
);
}
}
public
function
valiatingRequest
(
Request
$request
)
public
function
vali
d
atingRequest
(
Request
$request
)
{
{
$permissions
=
''
;
$permissions
=
''
;
...
...
app/Http/Controllers/Api/V1/UsersController.php
View file @
dfdc6994
...
@@ -32,7 +32,7 @@ class UsersController extends APIController
...
@@ -32,7 +32,7 @@ class UsersController extends APIController
$limit
=
$request
->
get
(
'paginate'
)
?
$request
->
get
(
'paginate'
)
:
25
;
$limit
=
$request
->
get
(
'paginate'
)
?
$request
->
get
(
'paginate'
)
:
25
;
return
UserResource
::
collection
(
return
UserResource
::
collection
(
$this
->
repository
->
get
Paginated
(
$limit
)
$this
->
repository
->
get
ForDataTable
(
1
,
false
)
->
paginate
(
$limit
)
);
);
}
}
...
@@ -53,12 +53,43 @@ class UsersController extends APIController
...
@@ -53,12 +53,43 @@ class UsersController extends APIController
return
$maindata
;
return
$maindata
;
}
}
/**
* Return the specified resource.
*
* @param Request
*
* @return \Illuminate\Http\Response
*/
public
function
deactivatedUserList
(
Request
$request
)
{
$limit
=
$request
->
get
(
'paginate'
)
?
$request
->
get
(
'paginate'
)
:
25
;
return
UserResource
::
collection
(
$this
->
repository
->
getForDataTable
(
0
,
false
)
->
paginate
(
$limit
)
);
}
/**
* Return the specified resource.
*
* @param User $user
*
* @return \Illuminate\Http\Response
*/
public
function
deleteUserList
(
Request
$request
)
{
$limit
=
$request
->
get
(
'paginate'
)
?
$request
->
get
(
'paginate'
)
:
25
;
return
UserResource
::
collection
(
$this
->
repository
->
getForDataTable
(
0
,
true
)
->
paginate
(
$limit
)
);
}
/**
/**
* Update the specified resource in storage.
* Update the specified resource in storage.
*/
*/
public
function
update
(
Request
$request
,
User
$user
)
public
function
update
(
Request
$request
,
User
$user
)
{
{
$validation
=
$this
->
valiatingRequest
(
$request
,
'edit'
,
$user
->
id
);
$validation
=
$this
->
vali
d
atingRequest
(
$request
,
'edit'
,
$user
->
id
);
if
(
$validation
->
fails
())
{
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
...
@@ -76,7 +107,7 @@ class UsersController extends APIController
...
@@ -76,7 +107,7 @@ class UsersController extends APIController
*/
*/
public
function
store
(
Request
$request
)
public
function
store
(
Request
$request
)
{
{
$validation
=
$this
->
valiatingRequest
(
$request
);
$validation
=
$this
->
vali
d
atingRequest
(
$request
);
if
(
$validation
->
fails
())
{
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
...
@@ -89,7 +120,7 @@ class UsersController extends APIController
...
@@ -89,7 +120,7 @@ class UsersController extends APIController
/**
/**
* Validation function to validate user input.
* Validation function to validate user input.
*/
*/
public
function
valiatingRequest
(
Request
$request
,
$string
=
''
,
$id
=
0
)
public
function
vali
d
atingRequest
(
Request
$request
,
$string
=
''
,
$id
=
0
)
{
{
$password
=
(
$string
==
'edit'
)
?
''
:
'required|min:6|confirmed'
;
$password
=
(
$string
==
'edit'
)
?
''
:
'required|min:6|confirmed'
;
$validation
=
Validator
::
make
(
$request
->
all
(),
[
$validation
=
Validator
::
make
(
$request
->
all
(),
[
...
...
app/Http/Resources/BlogCategoriesResource.php
0 → 100644
View file @
dfdc6994
<?php
namespace
App\Http\Resources
;
use
Illuminate\Http\Resources\Json\Resource
;
class
BlogCategoriesResource
extends
Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public
function
toArray
(
$request
)
{
return
[
'id'
=>
$this
->
id
,
'name'
=>
$this
->
name
,
'status'
=>
(
$this
->
isActive
())
?
"Active"
:
"InActive"
,
'created_at'
=>
optional
(
$this
->
created_at
)
->
toDateString
(),
'created_by'
=>
(
isset
(
$this
->
creator
))
?
optional
(
$this
->
creator
)
->
first_name
:
$this
->
user_name
,
];
}
}
app/Http/Resources/FaqsResource.php
0 → 100644
View file @
dfdc6994
<?php
namespace
App\Http\Resources
;
use
Illuminate\Http\Resources\Json\Resource
;
class
FaqsResource
extends
Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public
function
toArray
(
$request
)
{
return
[
'id'
=>
$this
->
id
,
'question'
=>
$this
->
question
,
'answer'
=>
$this
->
answer
,
'status'
=>
(
$this
->
isActive
())
?
"Active"
:
"InActive"
,
'created_at'
=>
$this
->
created_at
->
toDateString
(),
];
}
}
app/Http/Resources/PagesResource.php
0 → 100644
View file @
dfdc6994
<?php
namespace
App\Http\Resources
;
use
Illuminate\Http\Resources\Json\Resource
;
class
PagesResource
extends
Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public
function
toArray
(
$request
)
{
return
[
'id'
=>
$this
->
id
,
'title'
=>
$this
->
title
,
'status_label'
=>
$this
->
status_label
,
'status'
=>
(
$this
->
isActive
())
?
"Active"
:
"InActive"
,
'created_at'
=>
$this
->
created_at
->
toDateString
(),
'created_by'
=>
is_int
(
$this
->
created_by
)
?
optional
(
$this
->
owner
)
->
first_name
:
$this
->
created_by
,
];
}
}
routes/api.php
View file @
dfdc6994
...
@@ -29,11 +29,24 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
...
@@ -29,11 +29,24 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
});
});
// Users
// Users
Route
::
group
([
'prefix'
=>
'users'
],
function
()
{
Route
::
get
(
'deactiveUsers'
,
'UsersController@deactivatedUserList'
);
Route
::
get
(
'deleteUsers'
,
'UsersController@deleteUserList'
);
});
Route
::
resource
(
'users'
,
'UsersController'
);
Route
::
resource
(
'users'
,
'UsersController'
);
// Roles
// Roles
Route
::
resource
(
'roles'
,
'RolesController'
);
Route
::
resource
(
'roles'
,
'RolesController'
);
// Permission
// Permission
Route
::
resource
(
'permission'
,
'PermissionController'
);
Route
::
resource
(
'permission'
,
'PermissionController'
);
// Page
Route
::
resource
(
'pages'
,
'PagesController'
);
// Faqs
Route
::
resource
(
'faqs'
,
'FaqsController'
);
// Blog Categories
Route
::
resource
(
'blog_categories'
,
'BlogCategoriesController'
);
});
});
});
});
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