@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class StoreDummy extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - // |
|
28 | - ]; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + // |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |
@@ -8,16 +8,16 @@ |
||
8 | 8 | |
9 | 9 | class DummyModel extends Model |
10 | 10 | { |
11 | - use SoftDeletes; |
|
12 | - protected $table = 'DummyTableName'; |
|
13 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
14 | - protected $hidden = ['deleted_at']; |
|
15 | - protected $guarded = ['id']; |
|
16 | - public $fillable = []; // Add attributes here |
|
11 | + use SoftDeletes; |
|
12 | + protected $table = 'DummyTableName'; |
|
13 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
14 | + protected $hidden = ['deleted_at']; |
|
15 | + protected $guarded = ['id']; |
|
16 | + public $fillable = []; // Add attributes here |
|
17 | 17 | |
18 | - public static function boot() |
|
19 | - { |
|
20 | - parent::boot(); |
|
21 | - DummyModel::observe(DummyObserver::class); |
|
22 | - } |
|
18 | + public static function boot() |
|
19 | + { |
|
20 | + parent::boot(); |
|
21 | + DummyModel::observe(DummyObserver::class); |
|
22 | + } |
|
23 | 23 | } |
@@ -6,64 +6,64 @@ |
||
6 | 6 | |
7 | 7 | class DummyTableSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - /** |
|
17 | - * Insert the permissions related to DummyModelName table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * DummyModelName model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'index', |
|
26 | - 'model' => 'DummyModelName', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'show', |
|
32 | - 'model' => 'DummyModelName', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'store', |
|
38 | - 'model' => 'DummyModelName', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'update', |
|
44 | - 'model' => 'DummyModelName', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'destroy', |
|
50 | - 'model' => 'DummyModelName', |
|
51 | - 'created_at' => \DB::raw('NOW()'), |
|
52 | - 'updated_at' => \DB::raw('NOW()') |
|
53 | - ], |
|
54 | - [ |
|
55 | - 'name' => 'deleted', |
|
56 | - 'model' => 'DummyModelName', |
|
57 | - 'created_at' => \DB::raw('NOW()'), |
|
58 | - 'updated_at' => \DB::raw('NOW()') |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'name' => 'restore', |
|
62 | - 'model' => 'DummyModelName', |
|
63 | - 'created_at' => \DB::raw('NOW()'), |
|
64 | - 'updated_at' => \DB::raw('NOW()') |
|
65 | - ] |
|
66 | - ] |
|
67 | - ); |
|
68 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + /** |
|
17 | + * Insert the permissions related to DummyModelName table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * DummyModelName model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'index', |
|
26 | + 'model' => 'DummyModelName', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'show', |
|
32 | + 'model' => 'DummyModelName', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'store', |
|
38 | + 'model' => 'DummyModelName', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'update', |
|
44 | + 'model' => 'DummyModelName', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'destroy', |
|
50 | + 'model' => 'DummyModelName', |
|
51 | + 'created_at' => \DB::raw('NOW()'), |
|
52 | + 'updated_at' => \DB::raw('NOW()') |
|
53 | + ], |
|
54 | + [ |
|
55 | + 'name' => 'deleted', |
|
56 | + 'model' => 'DummyModelName', |
|
57 | + 'created_at' => \DB::raw('NOW()'), |
|
58 | + 'updated_at' => \DB::raw('NOW()') |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'name' => 'restore', |
|
62 | + 'model' => 'DummyModelName', |
|
63 | + 'created_at' => \DB::raw('NOW()'), |
|
64 | + 'updated_at' => \DB::raw('NOW()') |
|
65 | + ] |
|
66 | + ] |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |
@@ -7,45 +7,45 @@ |
||
7 | 7 | |
8 | 8 | class ReportRepository extends BaseRepository |
9 | 9 | { |
10 | - /** |
|
11 | - * Init new object. |
|
12 | - * |
|
13 | - * @param Report $model |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function __construct(Report $model) |
|
17 | - { |
|
18 | - parent::__construct($model); |
|
19 | - } |
|
10 | + /** |
|
11 | + * Init new object. |
|
12 | + * |
|
13 | + * @param Report $model |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function __construct(Report $model) |
|
17 | + { |
|
18 | + parent::__construct($model); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Render the given report db view based on the given |
|
23 | - * condition. |
|
24 | - * |
|
25 | - * @param mixed $report |
|
26 | - * @param array $conditions |
|
27 | - * @param integer $perPage |
|
28 | - * @return object |
|
29 | - */ |
|
30 | - public function renderReport($report, $conditions = [], $perPage = 0) |
|
31 | - { |
|
32 | - $report = ! filter_var($report, FILTER_VALIDATE_INT) ? $report : $this->find($report); |
|
33 | - /** |
|
34 | - * Fetch data from the report based on the given conditions. |
|
35 | - */ |
|
36 | - $report = \DB::table($report->view_name); |
|
37 | - unset($conditions['page']); |
|
38 | - if (count($conditions)) { |
|
39 | - $conditions = $this->constructConditions($conditions, $this->model); |
|
40 | - $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
41 | - } |
|
42 | - /** |
|
43 | - * Paginate or all data. |
|
44 | - */ |
|
45 | - if ($perPage) { |
|
46 | - return $report->paginate($perPage); |
|
47 | - } else { |
|
48 | - return $report->get(); |
|
49 | - } |
|
50 | - } |
|
21 | + /** |
|
22 | + * Render the given report db view based on the given |
|
23 | + * condition. |
|
24 | + * |
|
25 | + * @param mixed $report |
|
26 | + * @param array $conditions |
|
27 | + * @param integer $perPage |
|
28 | + * @return object |
|
29 | + */ |
|
30 | + public function renderReport($report, $conditions = [], $perPage = 0) |
|
31 | + { |
|
32 | + $report = ! filter_var($report, FILTER_VALIDATE_INT) ? $report : $this->find($report); |
|
33 | + /** |
|
34 | + * Fetch data from the report based on the given conditions. |
|
35 | + */ |
|
36 | + $report = \DB::table($report->view_name); |
|
37 | + unset($conditions['page']); |
|
38 | + if (count($conditions)) { |
|
39 | + $conditions = $this->constructConditions($conditions, $this->model); |
|
40 | + $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
41 | + } |
|
42 | + /** |
|
43 | + * Paginate or all data. |
|
44 | + */ |
|
45 | + if ($perPage) { |
|
46 | + return $report->paginate($perPage); |
|
47 | + } else { |
|
48 | + return $report->get(); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | } |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class Register extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'name' => 'nullable|string', |
|
28 | - 'email' => 'required|email|unique:users,email', |
|
29 | - 'password' => 'required|min:6' |
|
30 | - ]; |
|
31 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'name' => 'nullable|string', |
|
28 | + 'email' => 'required|email|unique:users,email', |
|
29 | + 'password' => 'required|min:6' |
|
30 | + ]; |
|
31 | + } |
|
32 | 32 | } |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | class AssignRoles extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'role_ids' => 'required|array', |
|
28 | - 'role_ids.*' => 'required|exists:roles,id' |
|
29 | - ]; |
|
30 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'role_ids' => 'required|array', |
|
28 | + 'role_ids.*' => 'required|exists:roles,id' |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |
@@ -8,52 +8,52 @@ |
||
8 | 8 | |
9 | 9 | class UserRepository extends BaseRepository |
10 | 10 | { |
11 | - /** |
|
12 | - * Init new object. |
|
13 | - * |
|
14 | - * @param AclUser $model |
|
15 | - * @return void |
|
16 | - */ |
|
17 | - public function __construct(AclUser $model) |
|
18 | - { |
|
19 | - parent::__construct($model); |
|
20 | - } |
|
11 | + /** |
|
12 | + * Init new object. |
|
13 | + * |
|
14 | + * @param AclUser $model |
|
15 | + * @return void |
|
16 | + */ |
|
17 | + public function __construct(AclUser $model) |
|
18 | + { |
|
19 | + parent::__construct($model); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Detach all roles from the given user. |
|
24 | - * |
|
25 | - * @param mixed $user |
|
26 | - * @return object |
|
27 | - */ |
|
28 | - public function detachRoles($user) |
|
29 | - { |
|
30 | - $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user); |
|
31 | - $user->roles()->detach(); |
|
32 | - } |
|
22 | + /** |
|
23 | + * Detach all roles from the given user. |
|
24 | + * |
|
25 | + * @param mixed $user |
|
26 | + * @return object |
|
27 | + */ |
|
28 | + public function detachRoles($user) |
|
29 | + { |
|
30 | + $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user); |
|
31 | + $user->roles()->detach(); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Attach role ids to the given user. |
|
36 | - * |
|
37 | - * @param mixed $user |
|
38 | - * @param array $roleIds |
|
39 | - * @return object |
|
40 | - */ |
|
41 | - public function attachRoles($user, $roleIds) |
|
42 | - { |
|
43 | - $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user); |
|
44 | - $user->roles()->attach($roleIds); |
|
45 | - } |
|
34 | + /** |
|
35 | + * Attach role ids to the given user. |
|
36 | + * |
|
37 | + * @param mixed $user |
|
38 | + * @param array $roleIds |
|
39 | + * @return object |
|
40 | + */ |
|
41 | + public function attachRoles($user, $roleIds) |
|
42 | + { |
|
43 | + $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user); |
|
44 | + $user->roles()->attach($roleIds); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Count the given user the given roles. |
|
49 | - * |
|
50 | - * @param mixed $user |
|
51 | - * @param string[] $roles |
|
52 | - * @return boolean |
|
53 | - */ |
|
54 | - public function countRoles($user, $roles) |
|
55 | - { |
|
56 | - $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user); |
|
57 | - return $user->roles()->whereIn('name', $roles)->count(); |
|
58 | - } |
|
47 | + /** |
|
48 | + * Count the given user the given roles. |
|
49 | + * |
|
50 | + * @param mixed $user |
|
51 | + * @param string[] $roles |
|
52 | + * @return boolean |
|
53 | + */ |
|
54 | + public function countRoles($user, $roles) |
|
55 | + { |
|
56 | + $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user); |
|
57 | + return $user->roles()->whereIn('name', $roles)->count(); |
|
58 | + } |
|
59 | 59 | } |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | class AssignPermissions extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'permission_ids' => 'required|array', |
|
28 | - 'permission_ids.*' => 'required|exists:permissions,id' |
|
29 | - ]; |
|
30 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'permission_ids' => 'required|array', |
|
28 | + 'permission_ids.*' => 'required|exists:permissions,id' |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |
@@ -7,33 +7,33 @@ |
||
7 | 7 | |
8 | 8 | class RoleService extends BaseService |
9 | 9 | { |
10 | - /** |
|
11 | - * Init new object. |
|
12 | - * |
|
13 | - * @param RoleRepository $repo |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function __construct(RoleRepository $repo) |
|
17 | - { |
|
18 | - parent::__construct($repo); |
|
19 | - } |
|
10 | + /** |
|
11 | + * Init new object. |
|
12 | + * |
|
13 | + * @param RoleRepository $repo |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function __construct(RoleRepository $repo) |
|
17 | + { |
|
18 | + parent::__construct($repo); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Assign the given permission ids to the given role. |
|
23 | - * |
|
24 | - * @param integer $roleId |
|
25 | - * @param array $permissionIds |
|
26 | - * @return object |
|
27 | - */ |
|
28 | - public function assignPermissions($roleId, $permissionIds) |
|
29 | - { |
|
30 | - $role = false; |
|
31 | - \DB::transaction(function () use ($roleId, $permissionIds, &$role) { |
|
32 | - $role = $this->repo->find($roleId); |
|
33 | - $this->repo->detachPermissions($role); |
|
34 | - $this->repo->attachPermissions($role, $permissionIds); |
|
35 | - }); |
|
21 | + /** |
|
22 | + * Assign the given permission ids to the given role. |
|
23 | + * |
|
24 | + * @param integer $roleId |
|
25 | + * @param array $permissionIds |
|
26 | + * @return object |
|
27 | + */ |
|
28 | + public function assignPermissions($roleId, $permissionIds) |
|
29 | + { |
|
30 | + $role = false; |
|
31 | + \DB::transaction(function () use ($roleId, $permissionIds, &$role) { |
|
32 | + $role = $this->repo->find($roleId); |
|
33 | + $this->repo->detachPermissions($role); |
|
34 | + $this->repo->attachPermissions($role, $permissionIds); |
|
35 | + }); |
|
36 | 36 | |
37 | - return $role; |
|
38 | - } |
|
37 | + return $role; |
|
38 | + } |
|
39 | 39 | } |