@@ -61,6 +61,6 @@ |
||
| 61 | 61 | $user->groups()->attach($group_ids); |
| 62 | 62 | }); |
| 63 | 63 | |
| 64 | - return \Core::users()->find($user_id); |
|
| 64 | + return \Core::users()->find($user_id); |
|
| 65 | 65 | } |
| 66 | 66 | } |
@@ -29,6 +29,6 @@ |
||
| 29 | 29 | $group->permissions()->attach($permission_ids); |
| 30 | 30 | }); |
| 31 | 31 | |
| 32 | - return \Core::groups()->find($group_id); |
|
| 32 | + return \Core::groups()->find($group_id); |
|
| 33 | 33 | } |
| 34 | 34 | } |
@@ -8,35 +8,35 @@ |
||
| 8 | 8 | |
| 9 | 9 | class GroupsController extends BaseApiController |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * The name of the model that is used by the base api controller |
|
| 13 | - * to preform actions like (add, edit ... etc). |
|
| 14 | - * @var string |
|
| 15 | - */ |
|
| 16 | - protected $model = 'groups'; |
|
| 11 | + /** |
|
| 12 | + * The name of the model that is used by the base api controller |
|
| 13 | + * to preform actions like (add, edit ... etc). |
|
| 14 | + * @var string |
|
| 15 | + */ |
|
| 16 | + protected $model = 'groups'; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * The validations rules used by the base api controller |
|
| 20 | - * to check before add. |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - protected $validationRules = [ |
|
| 24 | - 'name' => 'required|string|max:100|unique:groups,name,{id}' |
|
| 25 | - ]; |
|
| 18 | + /** |
|
| 19 | + * The validations rules used by the base api controller |
|
| 20 | + * to check before add. |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + protected $validationRules = [ |
|
| 24 | + 'name' => 'required|string|max:100|unique:groups,name,{id}' |
|
| 25 | + ]; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Handle an assign permissions to group request. |
|
| 29 | - * |
|
| 30 | - * @param \Illuminate\Http\Request $request |
|
| 31 | - * @return \Illuminate\Http\Response |
|
| 32 | - */ |
|
| 33 | - public function postAssignpermissions(Request $request) |
|
| 34 | - { |
|
| 35 | - $this->validate($request, [ |
|
| 36 | - 'permission_ids' => 'required|exists:permissions,id', |
|
| 37 | - 'group_id' => 'required|exists:groups,id' |
|
| 38 | - ]); |
|
| 27 | + /** |
|
| 28 | + * Handle an assign permissions to group request. |
|
| 29 | + * |
|
| 30 | + * @param \Illuminate\Http\Request $request |
|
| 31 | + * @return \Illuminate\Http\Response |
|
| 32 | + */ |
|
| 33 | + public function postAssignpermissions(Request $request) |
|
| 34 | + { |
|
| 35 | + $this->validate($request, [ |
|
| 36 | + 'permission_ids' => 'required|exists:permissions,id', |
|
| 37 | + 'group_id' => 'required|exists:groups,id' |
|
| 38 | + ]); |
|
| 39 | 39 | |
| 40 | - return \Response::json(\Core::groups()->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200); |
|
| 41 | - } |
|
| 40 | + return \Response::json(\Core::groups()->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200); |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -7,10 +7,10 @@ |
||
| 7 | 7 | |
| 8 | 8 | class PermissionsController extends BaseApiController |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * The name of the model that is used by the base api controller |
|
| 12 | - * to preform actions like (add, edit ... etc). |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $model = 'permissions'; |
|
| 10 | + /** |
|
| 11 | + * The name of the model that is used by the base api controller |
|
| 12 | + * to preform actions like (add, edit ... etc). |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $model = 'permissions'; |
|
| 16 | 16 | } |
@@ -13,17 +13,17 @@ |
||
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | 15 | Schema::create('users', function (Blueprint $table) { |
| 16 | - $table->increments('id'); |
|
| 17 | - $table->string('first_name',100)->nullable(); |
|
| 18 | - $table->string('last_name',100)->nullable(); |
|
| 19 | - $table->string('user_name',100)->nullable(); |
|
| 20 | - $table->text('address')->nullable(); |
|
| 21 | - $table->string('email')->unique(); |
|
| 22 | - $table->string('password', 60); |
|
| 23 | - $table->softDeletes(); |
|
| 24 | - $table->rememberToken(); |
|
| 25 | - $table->timestamps(); |
|
| 26 | - }); |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('first_name',100)->nullable(); |
|
| 18 | + $table->string('last_name',100)->nullable(); |
|
| 19 | + $table->string('user_name',100)->nullable(); |
|
| 20 | + $table->text('address')->nullable(); |
|
| 21 | + $table->string('email')->unique(); |
|
| 22 | + $table->string('password', 60); |
|
| 23 | + $table->softDeletes(); |
|
| 24 | + $table->rememberToken(); |
|
| 25 | + $table->timestamps(); |
|
| 26 | + }); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -12,21 +12,21 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('permissions', function (Blueprint $table) { |
|
| 16 | - $table->increments('id'); |
|
| 17 | - $table->string('name',100); |
|
| 18 | - $table->string('model',100); |
|
| 19 | - $table->softDeletes(); |
|
| 20 | - $table->timestamps(); |
|
| 21 | - $table->unique(array('name', 'model')); |
|
| 22 | - }); |
|
| 23 | - Schema::create('groups_permissions', function (Blueprint $table) { |
|
| 24 | - $table->increments('id'); |
|
| 25 | - $table->integer('group_id'); |
|
| 26 | - $table->integer('permission_id'); |
|
| 27 | - $table->softDeletes(); |
|
| 28 | - $table->timestamps(); |
|
| 29 | - }); |
|
| 15 | + Schema::create('permissions', function (Blueprint $table) { |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('name',100); |
|
| 18 | + $table->string('model',100); |
|
| 19 | + $table->softDeletes(); |
|
| 20 | + $table->timestamps(); |
|
| 21 | + $table->unique(array('name', 'model')); |
|
| 22 | + }); |
|
| 23 | + Schema::create('groups_permissions', function (Blueprint $table) { |
|
| 24 | + $table->increments('id'); |
|
| 25 | + $table->integer('group_id'); |
|
| 26 | + $table->integer('permission_id'); |
|
| 27 | + $table->softDeletes(); |
|
| 28 | + $table->timestamps(); |
|
| 29 | + }); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -13,19 +13,19 @@ |
||
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | 15 | Schema::create('groups', function (Blueprint $table) { |
| 16 | - $table->increments('id'); |
|
| 17 | - $table->string('name',100)->unique(); |
|
| 18 | - $table->softDeletes(); |
|
| 19 | - $table->timestamps(); |
|
| 20 | - }); |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('name',100)->unique(); |
|
| 18 | + $table->softDeletes(); |
|
| 19 | + $table->timestamps(); |
|
| 20 | + }); |
|
| 21 | 21 | |
| 22 | - Schema::create('users_groups', function (Blueprint $table) { |
|
| 23 | - $table->increments('id'); |
|
| 24 | - $table->integer('user_id'); |
|
| 25 | - $table->integer('group_id'); |
|
| 26 | - $table->softDeletes(); |
|
| 27 | - $table->timestamps(); |
|
| 28 | - }); |
|
| 22 | + Schema::create('users_groups', function (Blueprint $table) { |
|
| 23 | + $table->increments('id'); |
|
| 24 | + $table->integer('user_id'); |
|
| 25 | + $table->integer('group_id'); |
|
| 26 | + $table->softDeletes(); |
|
| 27 | + $table->timestamps(); |
|
| 28 | + }); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -3,127 +3,127 @@ |
||
| 3 | 3 | interface RepositoryInterface |
| 4 | 4 | { |
| 5 | 5 | /** |
| 6 | - * Fetch all records with relations from the storage. |
|
| 7 | - * |
|
| 8 | - * @param array $relations |
|
| 9 | - * @param array $sortBy |
|
| 10 | - * @param array $desc |
|
| 11 | - * @param array $columns |
|
| 12 | - * @return collection |
|
| 13 | - */ |
|
| 6 | + * Fetch all records with relations from the storage. |
|
| 7 | + * |
|
| 8 | + * @param array $relations |
|
| 9 | + * @param array $sortBy |
|
| 10 | + * @param array $desc |
|
| 11 | + * @param array $columns |
|
| 12 | + * @return collection |
|
| 13 | + */ |
|
| 14 | 14 | public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Fetch all records with relations from storage in pages |
|
| 18 | - * that matche the given query. |
|
| 19 | - * |
|
| 20 | - * @param string $query |
|
| 21 | - * @param integer $perPage |
|
| 22 | - * @param array $relations |
|
| 23 | - * @param array $sortBy |
|
| 24 | - * @param array $desc |
|
| 25 | - * @param array $columns |
|
| 26 | - * @return collection |
|
| 27 | - */ |
|
| 28 | - public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 16 | + /** |
|
| 17 | + * Fetch all records with relations from storage in pages |
|
| 18 | + * that matche the given query. |
|
| 19 | + * |
|
| 20 | + * @param string $query |
|
| 21 | + * @param integer $perPage |
|
| 22 | + * @param array $relations |
|
| 23 | + * @param array $sortBy |
|
| 24 | + * @param array $desc |
|
| 25 | + * @param array $columns |
|
| 26 | + * @return collection |
|
| 27 | + */ |
|
| 28 | + public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * Fetch all records with relations from storage in pages. |
|
| 32 | - * |
|
| 33 | - * @param integer $perPage |
|
| 34 | - * @param array $relations |
|
| 35 | - * @param array $sortBy |
|
| 36 | - * @param array $desc |
|
| 37 | - * @param array $columns |
|
| 38 | - * @return collection |
|
| 39 | - */ |
|
| 40 | - public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 31 | + * Fetch all records with relations from storage in pages. |
|
| 32 | + * |
|
| 33 | + * @param integer $perPage |
|
| 34 | + * @param array $relations |
|
| 35 | + * @param array $sortBy |
|
| 36 | + * @param array $desc |
|
| 37 | + * @param array $columns |
|
| 38 | + * @return collection |
|
| 39 | + */ |
|
| 40 | + public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * Fetch all records with relations based on |
|
| 44 | - * the given condition from storage in pages. |
|
| 45 | - * |
|
| 46 | - * @param array $conditions array of conditions |
|
| 47 | - * @param integer $perPage |
|
| 48 | - * @param array $relations |
|
| 49 | - * @param array $sortBy |
|
| 50 | - * @param array $desc |
|
| 51 | - * @param array $columns |
|
| 52 | - * @return collection |
|
| 53 | - */ |
|
| 54 | - public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 43 | + * Fetch all records with relations based on |
|
| 44 | + * the given condition from storage in pages. |
|
| 45 | + * |
|
| 46 | + * @param array $conditions array of conditions |
|
| 47 | + * @param integer $perPage |
|
| 48 | + * @param array $relations |
|
| 49 | + * @param array $sortBy |
|
| 50 | + * @param array $desc |
|
| 51 | + * @param array $columns |
|
| 52 | + * @return collection |
|
| 53 | + */ |
|
| 54 | + public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Save the given model/models to the storage. |
|
| 58 | - * |
|
| 59 | - * @param array $data |
|
| 60 | - * @param boolean $saveLog |
|
| 61 | - * @return object |
|
| 62 | - */ |
|
| 63 | - public function save(array $data, $saveLog = true); |
|
| 56 | + /** |
|
| 57 | + * Save the given model/models to the storage. |
|
| 58 | + * |
|
| 59 | + * @param array $data |
|
| 60 | + * @param boolean $saveLog |
|
| 61 | + * @return object |
|
| 62 | + */ |
|
| 63 | + public function save(array $data, $saveLog = true); |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Insert multiple records to the storage. |
|
| 67 | - * |
|
| 68 | - * @param array $data |
|
| 69 | - * @return object |
|
| 70 | - */ |
|
| 71 | - public function saveMany(array $data); |
|
| 65 | + /** |
|
| 66 | + * Insert multiple records to the storage. |
|
| 67 | + * |
|
| 68 | + * @param array $data |
|
| 69 | + * @return object |
|
| 70 | + */ |
|
| 71 | + public function saveMany(array $data); |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * Update record in the storage based on the given |
|
| 75 | - * condition. |
|
| 76 | - * |
|
| 77 | - * @param [type] $value condition value |
|
| 78 | - * @param array $data |
|
| 79 | - * @param string $attribute condition column name |
|
| 80 | - * @return integer affected rows |
|
| 81 | - */ |
|
| 82 | - public function update($value, array $data, $attribute = 'id'); |
|
| 74 | + * Update record in the storage based on the given |
|
| 75 | + * condition. |
|
| 76 | + * |
|
| 77 | + * @param [type] $value condition value |
|
| 78 | + * @param array $data |
|
| 79 | + * @param string $attribute condition column name |
|
| 80 | + * @return integer affected rows |
|
| 81 | + */ |
|
| 82 | + public function update($value, array $data, $attribute = 'id'); |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | - * Delete record from the storage based on the given |
|
| 86 | - * condition. |
|
| 87 | - * |
|
| 88 | - * @param [type] $value condition value |
|
| 89 | - * @param string $attribute condition column name |
|
| 90 | - * @return integer affected rows |
|
| 91 | - */ |
|
| 92 | - public function delete($value, $attribute = 'id'); |
|
| 85 | + * Delete record from the storage based on the given |
|
| 86 | + * condition. |
|
| 87 | + * |
|
| 88 | + * @param [type] $value condition value |
|
| 89 | + * @param string $attribute condition column name |
|
| 90 | + * @return integer affected rows |
|
| 91 | + */ |
|
| 92 | + public function delete($value, $attribute = 'id'); |
|
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | - * Fetch records from the storage based on the given |
|
| 96 | - * id. |
|
| 97 | - * |
|
| 98 | - * @param integer $id |
|
| 99 | - * @param array $relations |
|
| 100 | - * @param array $columns |
|
| 101 | - * @return object |
|
| 102 | - */ |
|
| 103 | - public function find($id, $relations = [], $columns = array('*')); |
|
| 95 | + * Fetch records from the storage based on the given |
|
| 96 | + * id. |
|
| 97 | + * |
|
| 98 | + * @param integer $id |
|
| 99 | + * @param array $relations |
|
| 100 | + * @param array $columns |
|
| 101 | + * @return object |
|
| 102 | + */ |
|
| 103 | + public function find($id, $relations = [], $columns = array('*')); |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * Fetch records from the storage based on the given |
|
| 107 | - * condition. |
|
| 108 | - * |
|
| 109 | - * @param array $conditions array of conditions |
|
| 110 | - * @param array $relations |
|
| 111 | - * @param array $sortBy |
|
| 112 | - * @param array $desc |
|
| 113 | - * @param array $columns |
|
| 114 | - * @return collection |
|
| 115 | - */ |
|
| 116 | - public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 106 | + * Fetch records from the storage based on the given |
|
| 107 | + * condition. |
|
| 108 | + * |
|
| 109 | + * @param array $conditions array of conditions |
|
| 110 | + * @param array $relations |
|
| 111 | + * @param array $sortBy |
|
| 112 | + * @param array $desc |
|
| 113 | + * @param array $columns |
|
| 114 | + * @return collection |
|
| 115 | + */ |
|
| 116 | + public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Fetch the first record fro the storage based on the given |
|
| 120 | - * condition. |
|
| 121 | - * |
|
| 122 | - * @param array $conditions array of conditions |
|
| 123 | - * @param [type] $value condition value |
|
| 124 | - * @param array $relations |
|
| 125 | - * @param array $columns |
|
| 126 | - * @return object |
|
| 127 | - */ |
|
| 128 | - public function first($conditions, $relations = [], $columns = array('*')); |
|
| 118 | + /** |
|
| 119 | + * Fetch the first record fro the storage based on the given |
|
| 120 | + * condition. |
|
| 121 | + * |
|
| 122 | + * @param array $conditions array of conditions |
|
| 123 | + * @param [type] $value condition value |
|
| 124 | + * @param array $relations |
|
| 125 | + * @param array $columns |
|
| 126 | + * @return object |
|
| 127 | + */ |
|
| 128 | + public function first($conditions, $relations = [], $columns = array('*')); |
|
| 129 | 129 | } |
| 130 | 130 | \ No newline at end of file |
@@ -4,13 +4,13 @@ |
||
| 4 | 4 | { |
| 5 | 5 | /** |
| 6 | 6 | * Construct the repository class name based on |
| 7 | - * the method name called, search in the |
|
| 8 | - * given namespaces for the class and |
|
| 9 | - * return an instance. |
|
| 10 | - * |
|
| 11 | - * @param string $name the called method name |
|
| 12 | - * @param array $arguments the method arguments |
|
| 13 | - * @return object |
|
| 14 | - */ |
|
| 7 | + * the method name called, search in the |
|
| 8 | + * given namespaces for the class and |
|
| 9 | + * return an instance. |
|
| 10 | + * |
|
| 11 | + * @param string $name the called method name |
|
| 12 | + * @param array $arguments the method arguments |
|
| 13 | + * @return object |
|
| 14 | + */ |
|
| 15 | 15 | public function __call($name, $arguments); |
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |