Commit 9c33c597 authored by cygnet's avatar cygnet

Resolved merge conflict by incorporating changes

parents 99ac8f95 1cb96da9
...@@ -8,7 +8,6 @@ use App\Repositories\Backend\Access\Permission\PermissionRepository; ...@@ -8,7 +8,6 @@ use App\Repositories\Backend\Access\Permission\PermissionRepository;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Validator; use Validator;
class PermissionController extends APIController class PermissionController extends APIController
{ {
protected $repository; protected $repository;
...@@ -50,7 +49,7 @@ class PermissionController extends APIController ...@@ -50,7 +49,7 @@ class PermissionController extends APIController
} }
/** /**
* Creates the Resourse for Role * Creates the Resourse for Role.
* *
* @param Request $request * @param Request $request
* *
...@@ -63,12 +62,12 @@ class PermissionController extends APIController ...@@ -63,12 +62,12 @@ class PermissionController extends APIController
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
} }
$this->repository->create($request->all()); $this->repository->create($request->all());
$permission = Permission::orderBy('created_at', 'desc')->first(); $permission = Permission::orderBy('created_at', 'desc')->first();
return new PermissionResource($permission); return new PermissionResource($permission);
} }
/** /**
* @param Role $role * @param Role $role
* @param UpdateRoleRequest $request * @param UpdateRoleRequest $request
...@@ -77,13 +76,12 @@ class PermissionController extends APIController ...@@ -77,13 +76,12 @@ class PermissionController extends APIController
*/ */
public function update(Request $request, Permission $permission) public function update(Request $request, Permission $permission)
{ {
$validation = $this->valiatingRequest($request); $validation = $this->valiatingRequest($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
} }
$this->repository->update($permission, $request->all()); $this->repository->update($permission, $request->all());
$permission = Permission::findOrfail($permission->id); $permission = Permission::findOrfail($permission->id);
...@@ -93,13 +91,14 @@ class PermissionController extends APIController ...@@ -93,13 +91,14 @@ class PermissionController extends APIController
public function valiatingRequest(Request $request) public function valiatingRequest(Request $request)
{ {
$validation = Validator::make($request->all(),[ $validation = Validator::make($request->all(), [
'name' => 'required|max:191', 'name' => 'required|max:191',
'display_name' => 'required|max:191', 'display_name' => 'required|max:191',
]); ]);
return $validation; return $validation;
} }
/** /**
* @param Role $role * @param Role $role
* @param DeleteRoleRequest $request * @param DeleteRoleRequest $request
...@@ -110,6 +109,6 @@ class PermissionController extends APIController ...@@ -110,6 +109,6 @@ class PermissionController extends APIController
{ {
$this->repository->delete($permission); $this->repository->delete($permission);
return ["message"=>"success"]; return ['message'=>'success'];
} }
} }
...@@ -8,7 +8,6 @@ use App\Repositories\Backend\Access\Role\RoleRepository; ...@@ -8,7 +8,6 @@ use App\Repositories\Backend\Access\Role\RoleRepository;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Validator; use Validator;
class RolesController extends APIController class RolesController extends APIController
{ {
protected $repository; protected $repository;
...@@ -50,7 +49,7 @@ class RolesController extends APIController ...@@ -50,7 +49,7 @@ class RolesController extends APIController
} }
/** /**
* Creates the Resourse for Role * Creates the Resourse for Role.
* *
* @param Request $request * @param Request $request
* *
...@@ -65,11 +64,9 @@ class RolesController extends APIController ...@@ -65,11 +64,9 @@ class RolesController extends APIController
$this->repository->create($request->all()); $this->repository->create($request->all());
return new RoleResource(Role::orderBy('created_at', 'desc')->first()); return new RoleResource(Role::orderBy('created_at', 'desc')->first());
} }
/** /**
* @param Role $role * @param Role $role
* @param UpdateRoleRequest $request * @param UpdateRoleRequest $request
...@@ -78,7 +75,6 @@ class RolesController extends APIController ...@@ -78,7 +75,6 @@ class RolesController extends APIController
*/ */
public function update(Request $request, Role $role) public function update(Request $request, Role $role)
{ {
$validation = $this->valiatingRequest($request); $validation = $this->valiatingRequest($request);
if ($validation->fails()) { if ($validation->fails()) {
...@@ -87,7 +83,7 @@ class RolesController extends APIController ...@@ -87,7 +83,7 @@ class RolesController extends APIController
$this->repository->update($role, $request->all()); $this->repository->update($role, $request->all());
$role= Role::findOrfail($role->id); $role = Role::findOrfail($role->id);
return new RoleResource($role); return new RoleResource($role);
} }
...@@ -96,17 +92,18 @@ class RolesController extends APIController ...@@ -96,17 +92,18 @@ class RolesController extends APIController
{ {
$permissions = ''; $permissions = '';
if ($request->post("associated_permissions") != 'all') { if ($request->post('associated_permissions') != 'all') {
$permissions = 'required'; $permissions = 'required';
} }
$validation = Validator::make($request->all(), [ $validation = Validator::make($request->all(), [
'name' => 'required|max:191', 'name' => 'required|max:191',
'permissions' => $permissions, 'permissions' => $permissions,
]); ]);
return $validation; return $validation;
} }
/** /**
* @param Role $role * @param Role $role
* @param DeleteRoleRequest $request * @param DeleteRoleRequest $request
...@@ -117,6 +114,6 @@ class RolesController extends APIController ...@@ -117,6 +114,6 @@ class RolesController extends APIController
{ {
$this->repository->delete($role); $this->repository->delete($role);
return ["message"=>"success"]; return ['message'=>'success'];
} }
} }
...@@ -6,7 +6,6 @@ use App\Http\Resources\UserResource; ...@@ -6,7 +6,6 @@ use App\Http\Resources\UserResource;
use App\Models\Access\User\User; use App\Models\Access\User\User;
use App\Repositories\Backend\Access\User\UserRepository; use App\Repositories\Backend\Access\User\UserRepository;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Validator; use Validator;
class UsersController extends APIController class UsersController extends APIController
...@@ -47,10 +46,11 @@ class UsersController extends APIController ...@@ -47,10 +46,11 @@ class UsersController extends APIController
public function show(User $user) public function show(User $user)
{ {
$data = new UserResource($user); $data = new UserResource($user);
$history["history"] = history()->renderEntity('User', $user->id); $history['history'] = history()->renderEntity('User', $user->id);
$maindata = $data->toArray($user); $maindata = $data->toArray($user);
$maindata = array_merge($maindata, $history); $maindata = array_merge($maindata, $history);
return $maindata;
return $maindata;
} }
/** /**
...@@ -79,7 +79,6 @@ class UsersController extends APIController ...@@ -79,7 +79,6 @@ class UsersController extends APIController
public function deleteUserList(Request $request) public function deleteUserList(Request $request)
{ {
$limit = $request->get('paginate') ? $request->get('paginate') : 25; $limit = $request->get('paginate') ? $request->get('paginate') : 25;
return UserResource::collection( return UserResource::collection(
$this->repository->getForDataTable(0, true)->paginate($limit) $this->repository->getForDataTable(0, true)->paginate($limit)
); );
...@@ -90,12 +89,12 @@ class UsersController extends APIController ...@@ -90,12 +89,12 @@ class UsersController extends APIController
*/ */
public function update(Request $request, User $user) public function update(Request $request, User $user)
{ {
$validation = $this->valiatingRequest($request,"edit",$user->id); $validation = $this->valiatingRequest($request, 'edit', $user->id);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
} }
$this->repository->update($user, $request); $this->repository->update($user, $request);
$user = User::findOrfail($user->id); $user = User::findOrfail($user->id);
...@@ -114,28 +113,31 @@ class UsersController extends APIController ...@@ -114,28 +113,31 @@ class UsersController extends APIController
return $this->throwValidation($validation->messages()->first()); return $this->throwValidation($validation->messages()->first());
} }
$this->repository->create($request); $this->repository->create($request);
return new UserResource(User::orderBy('created_at', 'desc')->first()); return new UserResource(User::orderBy('created_at', 'desc')->first());
} }
/** /**
* Validation function to validate user input * Validation function to validate user input.
*/ */
public function valiatingRequest(Request $request,$string="",$id=0) public function valiatingRequest(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(), [
'first_name' => 'required|max:255', 'first_name' => 'required|max:255',
'last_name' => 'required|max:255', 'last_name' => 'required|max:255',
'email' => 'required|max:255|email|unique:users,email,'.$id, 'email' => 'required|max:255|email|unique:users,email,'.$id,
'password' => $password, 'password' => $password,
'assignees_roles' => 'required', 'assignees_roles' => 'required',
'permissions' => 'required', 'permissions' => 'required',
]); ]);
return $validation; return $validation;
} }
/** /**
* Api to delete the resource * Api to delete the resource.
*
* @param Role $role * @param Role $role
* @param DeleteRoleRequest $request * @param DeleteRoleRequest $request
* *
...@@ -145,6 +147,6 @@ class UsersController extends APIController ...@@ -145,6 +147,6 @@ class UsersController extends APIController
{ {
$this->repository->delete($user); $this->repository->delete($user);
return ["message" => "success"]; return ['message' => 'success'];
} }
} }
<?php
namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
/**
* Class TrustProxies.
*/
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var string
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}
...@@ -18,9 +18,9 @@ class RoleResource extends Resource ...@@ -18,9 +18,9 @@ class RoleResource extends Resource
return [ return [
'id' => $this->id, 'id' => $this->id,
'name' => $this->name, 'name' => $this->name,
"permission" => ($this->all)? "All": optional($this->permissions)->pluck("display_name"), 'permission' => ($this->all) ? 'All' : optional($this->permissions)->pluck('display_name'),
"noofuses" => $this->users->count(), 'noofuses' => $this->users->count(),
"sort" => $this->sort, 'sort' => $this->sort,
]; ];
} }
} }
...@@ -16,16 +16,15 @@ class UserResource extends Resource ...@@ -16,16 +16,15 @@ class UserResource extends Resource
public function toArray($request) public function toArray($request)
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'first_name' => $this->first_name, 'first_name' => $this->first_name,
'last_name' => $this->last_name, 'last_name' => $this->last_name,
'email' => $this->email, 'email' => $this->email,
'confirmed' => $this->confirmed, 'confirmed' => $this->confirmed,
'role' => optional($this->roles()->first())->name, 'role' => optional($this->roles()->first())->name,
'registered_at' => $this->created_at->toIso8601String(), 'registered_at' => $this->created_at->toIso8601String(),
'last_updated_at' => $this->updated_at->toIso8601String(), 'last_updated_at' => $this->updated_at->toIso8601String(),
]; ];
} }
} }
...@@ -137,7 +137,7 @@ class UserRepository extends BaseRepository ...@@ -137,7 +137,7 @@ class UserRepository extends BaseRepository
$data = $request->except('assignees_roles', 'permissions'); $data = $request->except('assignees_roles', 'permissions');
$roles = $request->get('assignees_roles'); $roles = $request->get('assignees_roles');
$permissions = $request->get('permissions'); $permissions = $request->get('permissions');
$this->checkUserByEmail($data, $user); $this->checkUserByEmail($data, $user);
DB::transaction(function () use ($user, $data, $roles, $permissions) { DB::transaction(function () use ($user, $data, $roles, $permissions) {
......
...@@ -11,31 +11,31 @@ ...@@ -11,31 +11,31 @@
"license": "MIT", "license": "MIT",
"type": "project", "type": "project",
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.1.3",
"arcanedev/log-viewer": "^4.4", "arcanedev/log-viewer": "^4.5",
"arcanedev/no-captcha": "^5.0", "arcanedev/no-captcha": "^5.0",
"codedungeon/phpunit-result-printer": "0.4.4",
"creativeorange/gravatar": "~1.0", "creativeorange/gravatar": "~1.0",
"davejamesmiller/laravel-breadcrumbs": "^4.1", "davejamesmiller/laravel-breadcrumbs": "^5.0",
"doctrine/dbal": "^2.6", "doctrine/dbal": "^2.6",
"fideloper/proxy": "~3.3", "fideloper/proxy": "~4.0",
"hieu-le/active": "^3.5", "hieu-le/active": "^3.5",
"laravel/framework": "5.5.*", "laravel/framework": "5.6.*",
"laravel/socialite": "^3.0", "laravel/socialite": "^3.0",
"laravel/tinker": "~1.0", "laravel/tinker": "~1.0",
"laravelcollective/html": "^5.5.0", "laravelcollective/html": "^5.4.0",
"tymon/jwt-auth": "dev-develop", "tymon/jwt-auth": "dev-develop",
"unisharp/laravel-filemanager": "~1.8", "unisharp/laravel-filemanager": "~1.8",
"yajra/laravel-datatables-oracle": "~8.0" "yajra/laravel-datatables-oracle": "~8.0"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-debugbar": "^3.0", "barryvdh/laravel-debugbar": "^3.0",
"codedungeon/phpunit-result-printer": "^0.6.0",
"bvipul/generator": "^0.9.1", "bvipul/generator": "^0.9.1",
"filp/whoops": "~2.0", "filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4", "fzaninotto/faker": "~1.4",
"laravel/browser-kit-testing": "^2.0", "laravel/browser-kit-testing": "^4.0.0",
"mockery/mockery": "0.9.*", "mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0", "phpunit/phpunit": "~7.0",
"xethron/migrations-generator": "2.0.2" "xethron/migrations-generator": "2.0.2"
}, },
"autoload": { "autoload": {
...@@ -69,14 +69,6 @@ ...@@ -69,14 +69,6 @@
"post-create-project-cmd": [ "post-create-project-cmd": [
"php artisan key:generate" "php artisan key:generate"
], ],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
],
"post-autoload-dump": [ "post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover" "@php artisan package:discover"
......
This diff is collapsed.
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon"
|
*/
'driver' => 'bcrypt',
];
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'days' => 7,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
],
'syslog' => [
'driver' => 'syslog',
'level' => 'debug',
],
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
],
],
];
<?php
return [
/*
* Set trusted proxy IP addresses.
*
* Both IPv4 and IPv6 addresses are
* supported, along with CIDR notation.
*
* The "*" character is syntactic sugar
* within TrustedProxy to trust any proxy
* that connects directly to your server,
* a requirement when you cannot know the address
* of your proxy (e.g. if using Rackspace balancers).
*
* The "**" character is syntactic sugar within
* TrustedProxy to trust not just any proxy that
* connects directly to your server, but also
* proxies that connect to those proxies, and all
* the way back until you reach the original source
* IP. It will mean that $request->getClientIp()
* always gets the originating client IP, no matter
* how many proxies that client's request has
* subsequently passed through.
*/
'proxies' => [
'192.168.1.10',
],
/*
* Or, to trust all proxies that connect
* directly to your server, uncomment this:
*/
// 'proxies' => '*',
/*
* Or, to trust ALL proxies, including those that
* are in a chain of forwarding, uncomment this:
*/
// 'proxies' => '**',
/*
* Default Header Names
*
* Change these if the proxy does
* not send the default header names.
*
* Note that headers such as X-Forwarded-For
* are transformed to HTTP_X_FORWARDED_FOR format.
*
* The following are Symfony defaults, found in
* \Symfony\Component\HttpFoundation\Request::$trustedHeaders
*
* You may optionally set headers to 'null' here if you'd like
* for them to be considered untrusted instead. Ex:
*
* Illuminate\Http\Request::HEADER_CLIENT_HOST => null,
*
* WARNING: If you're using AWS Elastic Load Balancing or Heroku,
* the FORWARDED and X_FORWARDED_HOST headers should be set to null
* as they are currently unsupported there.
*/
'headers' => [
(defined('Illuminate\Http\Request::HEADER_FORWARDED') ? Illuminate\Http\Request::HEADER_FORWARDED : 'forwarded') => 'FORWARDED',
Illuminate\Http\Request::HEADER_CLIENT_IP => 'X_FORWARDED_FOR',
Illuminate\Http\Request::HEADER_CLIENT_HOST => 'X_FORWARDED_HOST',
Illuminate\Http\Request::HEADER_CLIENT_PROTO => 'X_FORWARDED_PROTO',
Illuminate\Http\Request::HEADER_CLIENT_PORT => 'X_FORWARDED_PORT',
],
];
...@@ -37,7 +37,7 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio ...@@ -37,7 +37,7 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
// Roles // Roles
Route::resource('roles', 'RolesController'); Route::resource('roles', 'RolesController');
// Permission // Permission
Route::resource('permission', 'PermissionController'); Route::resource('permission', 'PermissionController');
// Page // Page
......
...@@ -14,7 +14,7 @@ class LogViewerRouteTest extends BrowserKitTestCase ...@@ -14,7 +14,7 @@ class LogViewerRouteTest extends BrowserKitTestCase
{ {
$this->actingAs($this->admin) $this->actingAs($this->admin)
->visit('/admin/log-viewer') ->visit('/admin/log-viewer')
->see('Log Viewer'); ->see('LogViewer');
} }
/** @test **/ /** @test **/
...@@ -25,19 +25,19 @@ class LogViewerRouteTest extends BrowserKitTestCase ...@@ -25,19 +25,19 @@ class LogViewerRouteTest extends BrowserKitTestCase
->see('Logs'); ->see('Logs');
} }
/** @test **/ /* @test **/
public function admin_users_can_see_logviewer_single_date() /*public function admin_users_can_see_logviewer_single_date()
{ {
$this->actingAs($this->admin) $this->actingAs($this->admin)
->visit('/admin/log-viewer/logs/'.date('Y-m-d')) ->visit('/admin/log-viewer/logs/'.date('Y-m-d'))
->see('Log ['.date('Y-m-d').']'); ->see('Log ['.date('Y-m-d').']');
} }*/
/** @test **/ /* @test **/
public function admin_users_can_see_logviewer_single_date_type() /*public function admin_users_can_see_logviewer_single_date_type()
{ {
$this->actingAs($this->admin) $this->actingAs($this->admin)
->visit('/admin/log-viewer/logs/'.date('Y-m-d').'/error') ->visit('/admin/log-viewer/logs/'.date('Y-m-d').'/error')
->see('Log ['.date('Y-m-d').']'); ->see('Log ['.date('Y-m-d').']');
} }*/
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment