@@ -2,81 +2,81 @@ |
||
| 2 | 2 | |
| 3 | 3 | class ErrorHandler |
| 4 | 4 | { |
| 5 | - public function unAuthorized() |
|
| 6 | - { |
|
| 7 | - $error = ['status' => 401, 'message' => 'Please login before any action']; |
|
| 8 | - abort($error['status'], $error['message']); |
|
| 9 | - } |
|
| 5 | + public function unAuthorized() |
|
| 6 | + { |
|
| 7 | + $error = ['status' => 401, 'message' => 'Please login before any action']; |
|
| 8 | + abort($error['status'], $error['message']); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function tokenExpired() |
|
| 12 | - { |
|
| 13 | - $error = ['status' => 403, 'message' => 'Login token expired']; |
|
| 14 | - abort($error['status'], $error['message']); |
|
| 15 | - } |
|
| 11 | + public function tokenExpired() |
|
| 12 | + { |
|
| 13 | + $error = ['status' => 403, 'message' => 'Login token expired']; |
|
| 14 | + abort($error['status'], $error['message']); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function noPermissions() |
|
| 18 | - { |
|
| 19 | - $error = ['status' => 403, 'message' => 'No permissions']; |
|
| 20 | - abort($error['status'], $error['message']); |
|
| 21 | - } |
|
| 17 | + public function noPermissions() |
|
| 18 | + { |
|
| 19 | + $error = ['status' => 403, 'message' => 'No permissions']; |
|
| 20 | + abort($error['status'], $error['message']); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function loginFailed() |
|
| 24 | - { |
|
| 25 | - $error = ['status' => 400, 'message' => 'Wrong mail or password']; |
|
| 26 | - abort($error['status'], $error['message']); |
|
| 27 | - } |
|
| 23 | + public function loginFailed() |
|
| 24 | + { |
|
| 25 | + $error = ['status' => 400, 'message' => 'Wrong mail or password']; |
|
| 26 | + abort($error['status'], $error['message']); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function redisNotRunning() |
|
| 30 | - { |
|
| 31 | - $error = ['status' => 400, 'message' => 'Your redis notification server isn\'t running']; |
|
| 32 | - abort($error['status'], $error['message']); |
|
| 33 | - } |
|
| 29 | + public function redisNotRunning() |
|
| 30 | + { |
|
| 31 | + $error = ['status' => 400, 'message' => 'Your redis notification server isn\'t running']; |
|
| 32 | + abort($error['status'], $error['message']); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public function dbQueryError() |
|
| 36 | - { |
|
| 37 | - $error = ['status' => 400, 'message' => 'Please check the given inputes']; |
|
| 38 | - abort($error['status'], $error['message']); |
|
| 39 | - } |
|
| 35 | + public function dbQueryError() |
|
| 36 | + { |
|
| 37 | + $error = ['status' => 400, 'message' => 'Please check the given inputes']; |
|
| 38 | + abort($error['status'], $error['message']); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function cannotCreateSetting() |
|
| 42 | - { |
|
| 43 | - $error = ['status' => 400, 'message' => 'Can\'t create setting']; |
|
| 44 | - abort($error['status'], $error['message']); |
|
| 45 | - } |
|
| 41 | + public function cannotCreateSetting() |
|
| 42 | + { |
|
| 43 | + $error = ['status' => 400, 'message' => 'Can\'t create setting']; |
|
| 44 | + abort($error['status'], $error['message']); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public function cannotUpdateSettingKey() |
|
| 48 | - { |
|
| 49 | - $error = ['status' => 400, 'message' => 'Can\'t update setting key']; |
|
| 50 | - abort($error['status'], $error['message']); |
|
| 51 | - } |
|
| 47 | + public function cannotUpdateSettingKey() |
|
| 48 | + { |
|
| 49 | + $error = ['status' => 400, 'message' => 'Can\'t update setting key']; |
|
| 50 | + abort($error['status'], $error['message']); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function userIsBlocked() |
|
| 54 | - { |
|
| 55 | - $error = ['status' => 403, 'message' => 'You have been blocked']; |
|
| 56 | - abort($error['status'], $error['message']); |
|
| 57 | - } |
|
| 53 | + public function userIsBlocked() |
|
| 54 | + { |
|
| 55 | + $error = ['status' => 403, 'message' => 'You have been blocked']; |
|
| 56 | + abort($error['status'], $error['message']); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function invalidResetToken() |
|
| 60 | - { |
|
| 61 | - $error = ['status' => 400, 'message' => 'Reset password token is invalid']; |
|
| 62 | - abort($error['status'], $error['message']); |
|
| 63 | - } |
|
| 59 | + public function invalidResetToken() |
|
| 60 | + { |
|
| 61 | + $error = ['status' => 400, 'message' => 'Reset password token is invalid']; |
|
| 62 | + abort($error['status'], $error['message']); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - public function invalidResetPassword() |
|
| 66 | - { |
|
| 67 | - $error = ['status' => 400, 'message' => 'Reset password is invalid']; |
|
| 68 | - abort($error['status'], $error['message']); |
|
| 69 | - } |
|
| 65 | + public function invalidResetPassword() |
|
| 66 | + { |
|
| 67 | + $error = ['status' => 400, 'message' => 'Reset password is invalid']; |
|
| 68 | + abort($error['status'], $error['message']); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public function notFound($text) |
|
| 72 | - { |
|
| 73 | - $error = ['status' => 404, 'message' => 'The requested ' . $text . ' not found']; |
|
| 74 | - abort($error['status'], $error['message']); |
|
| 75 | - } |
|
| 71 | + public function notFound($text) |
|
| 72 | + { |
|
| 73 | + $error = ['status' => 404, 'message' => 'The requested ' . $text . ' not found']; |
|
| 74 | + abort($error['status'], $error['message']); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - public function generalError() |
|
| 78 | - { |
|
| 79 | - $error = ['status' => 404, 'message' => 'Something went wrong']; |
|
| 80 | - abort($error['status'], $error['message']); |
|
| 81 | - } |
|
| 77 | + public function generalError() |
|
| 78 | + { |
|
| 79 | + $error = ['status' => 404, 'message' => 'Something went wrong']; |
|
| 80 | + abort($error['status'], $error['message']); |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | \ No newline at end of file |
@@ -5,27 +5,27 @@ |
||
| 5 | 5 | |
| 6 | 6 | class PasswordResets extends Migration |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Run the migrations. |
|
| 10 | - * |
|
| 11 | - * @return void |
|
| 12 | - */ |
|
| 13 | - public function up() |
|
| 14 | - { |
|
| 15 | - Schema::create('password_resets', function (Blueprint $table) { |
|
| 16 | - $table->string('email')->index(); |
|
| 17 | - $table->string('token')->index(); |
|
| 18 | - $table->timestamp('created_at'); |
|
| 19 | - }); |
|
| 20 | - } |
|
| 8 | + /** |
|
| 9 | + * Run the migrations. |
|
| 10 | + * |
|
| 11 | + * @return void |
|
| 12 | + */ |
|
| 13 | + public function up() |
|
| 14 | + { |
|
| 15 | + Schema::create('password_resets', function (Blueprint $table) { |
|
| 16 | + $table->string('email')->index(); |
|
| 17 | + $table->string('token')->index(); |
|
| 18 | + $table->timestamp('created_at'); |
|
| 19 | + }); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Reverse the migrations. |
|
| 24 | - * |
|
| 25 | - * @return void |
|
| 26 | - */ |
|
| 27 | - public function down() |
|
| 28 | - { |
|
| 29 | - Schema::drop('password_resets'); |
|
| 30 | - } |
|
| 22 | + /** |
|
| 23 | + * Reverse the migrations. |
|
| 24 | + * |
|
| 25 | + * @return void |
|
| 26 | + */ |
|
| 27 | + public function down() |
|
| 28 | + { |
|
| 29 | + Schema::drop('password_resets'); |
|
| 30 | + } |
|
| 31 | 31 | } |
@@ -13,15 +13,15 @@ |
||
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | 15 | Schema::create('users', function (Blueprint $table) { |
| 16 | - $table->increments('id'); |
|
| 17 | - $table->string('name',100)->nullable(); |
|
| 18 | - $table->string('email')->unique(); |
|
| 19 | - $table->string('password', 60); |
|
| 20 | - $table->boolean('blocked', 0); |
|
| 21 | - $table->softDeletes(); |
|
| 22 | - $table->rememberToken(); |
|
| 23 | - $table->timestamps(); |
|
| 24 | - }); |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('name',100)->nullable(); |
|
| 18 | + $table->string('email')->unique(); |
|
| 19 | + $table->string('password', 60); |
|
| 20 | + $table->boolean('blocked', 0); |
|
| 21 | + $table->softDeletes(); |
|
| 22 | + $table->rememberToken(); |
|
| 23 | + $table->timestamps(); |
|
| 24 | + }); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -6,26 +6,26 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ApiSkeletonServiceProvider extends ServiceProvider |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Perform post-registration booting of services. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function boot() |
|
| 15 | - { |
|
| 16 | - $this->publishes([ |
|
| 17 | - __DIR__.'/Modules' => app_path('Modules'), |
|
| 18 | - __DIR__.'/Modules/V1/Acl/emails' => base_path('resources/views/auth/emails'), |
|
| 19 | - ]); |
|
| 20 | - } |
|
| 9 | + /** |
|
| 10 | + * Perform post-registration booting of services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | + $this->publishes([ |
|
| 17 | + __DIR__.'/Modules' => app_path('Modules'), |
|
| 18 | + __DIR__.'/Modules/V1/Acl/emails' => base_path('resources/views/auth/emails'), |
|
| 19 | + ]); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Register any package services. |
|
| 24 | - * |
|
| 25 | - * @return void |
|
| 26 | - */ |
|
| 27 | - public function register() |
|
| 28 | - { |
|
| 29 | - // |
|
| 30 | - } |
|
| 22 | + /** |
|
| 23 | + * Register any package services. |
|
| 24 | + * |
|
| 25 | + * @return void |
|
| 26 | + */ |
|
| 27 | + public function register() |
|
| 28 | + { |
|
| 29 | + // |
|
| 30 | + } |
|
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -5,59 +5,59 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class SettingsObserver { |
| 7 | 7 | |
| 8 | - public function saving($model) |
|
| 9 | - { |
|
| 10 | - // |
|
| 11 | - } |
|
| 12 | - |
|
| 13 | - public function saved($model) |
|
| 14 | - { |
|
| 15 | - // |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * Prevent the creating of the settings. |
|
| 20 | - * |
|
| 21 | - * @param object $model the model beign created. |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function creating($model) |
|
| 25 | - { |
|
| 26 | - \ErrorHandler::cannotCreateSetting(); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function created($model) |
|
| 30 | - { |
|
| 31 | - // |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Prevent updating of the setting key. |
|
| 36 | - * |
|
| 37 | - * @param object $model the model beign updated. |
|
| 38 | - * @return void |
|
| 39 | - */ |
|
| 40 | - public function updating($model) |
|
| 41 | - { |
|
| 42 | - if ($model->getOriginal()['key'] !== $model->key) |
|
| 43 | - { |
|
| 44 | - \ErrorHandler::cannotUpdateSettingKey(); |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - public function updated($model) |
|
| 49 | - { |
|
| 50 | - // |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function deleting($model) |
|
| 54 | - { |
|
| 55 | - // |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - public function deleted($model) |
|
| 59 | - { |
|
| 60 | - // |
|
| 61 | - } |
|
| 8 | + public function saving($model) |
|
| 9 | + { |
|
| 10 | + // |
|
| 11 | + } |
|
| 12 | + |
|
| 13 | + public function saved($model) |
|
| 14 | + { |
|
| 15 | + // |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * Prevent the creating of the settings. |
|
| 20 | + * |
|
| 21 | + * @param object $model the model beign created. |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function creating($model) |
|
| 25 | + { |
|
| 26 | + \ErrorHandler::cannotCreateSetting(); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public function created($model) |
|
| 30 | + { |
|
| 31 | + // |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Prevent updating of the setting key. |
|
| 36 | + * |
|
| 37 | + * @param object $model the model beign updated. |
|
| 38 | + * @return void |
|
| 39 | + */ |
|
| 40 | + public function updating($model) |
|
| 41 | + { |
|
| 42 | + if ($model->getOriginal()['key'] !== $model->key) |
|
| 43 | + { |
|
| 44 | + \ErrorHandler::cannotUpdateSettingKey(); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + public function updated($model) |
|
| 49 | + { |
|
| 50 | + // |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function deleting($model) |
|
| 54 | + { |
|
| 55 | + // |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + public function deleted($model) |
|
| 59 | + { |
|
| 60 | + // |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | \ No newline at end of file |
@@ -15,23 +15,23 @@ |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Set the notification notified to true. |
|
| 19 | - * |
|
| 20 | - * @param integer $id |
|
| 21 | - * @return object |
|
| 22 | - */ |
|
| 23 | - public function notified($id) |
|
| 24 | - { |
|
| 25 | - return $this->save(['id' => $id, 'notified' => 1]); |
|
| 26 | - } |
|
| 18 | + * Set the notification notified to true. |
|
| 19 | + * |
|
| 20 | + * @param integer $id |
|
| 21 | + * @return object |
|
| 22 | + */ |
|
| 23 | + public function notified($id) |
|
| 24 | + { |
|
| 25 | + return $this->save(['id' => $id, 'notified' => 1]); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Set the notification notified to all. |
|
| 30 | - * |
|
| 31 | - * @return void |
|
| 32 | - */ |
|
| 33 | - public function notifyAll() |
|
| 34 | - { |
|
| 35 | - \Core::notifications()->update(false, ['notified' => 1], 'notified'); |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * Set the notification notified to all. |
|
| 30 | + * |
|
| 31 | + * @return void |
|
| 32 | + */ |
|
| 33 | + public function notifyAll() |
|
| 34 | + { |
|
| 35 | + \Core::notifications()->update(false, ['notified' => 1], 'notified'); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -3,107 +3,107 @@ |
||
| 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 | 65 | /** |
| 66 | - * Delete record from the storage based on the given |
|
| 67 | - * condition. |
|
| 68 | - * |
|
| 69 | - * @param var $value condition value |
|
| 70 | - * @param string $attribute condition column name |
|
| 71 | - * @return integer affected rows |
|
| 72 | - */ |
|
| 73 | - public function delete($value, $attribute = 'id'); |
|
| 66 | + * Delete record from the storage based on the given |
|
| 67 | + * condition. |
|
| 68 | + * |
|
| 69 | + * @param var $value condition value |
|
| 70 | + * @param string $attribute condition column name |
|
| 71 | + * @return integer affected rows |
|
| 72 | + */ |
|
| 73 | + public function delete($value, $attribute = 'id'); |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | - * Fetch records from the storage based on the given |
|
| 77 | - * id. |
|
| 78 | - * |
|
| 79 | - * @param integer $id |
|
| 80 | - * @param array $relations |
|
| 81 | - * @param array $columns |
|
| 82 | - * @return object |
|
| 83 | - */ |
|
| 84 | - public function find($id, $relations = [], $columns = array('*')); |
|
| 76 | + * Fetch records from the storage based on the given |
|
| 77 | + * id. |
|
| 78 | + * |
|
| 79 | + * @param integer $id |
|
| 80 | + * @param array $relations |
|
| 81 | + * @param array $columns |
|
| 82 | + * @return object |
|
| 83 | + */ |
|
| 84 | + public function find($id, $relations = [], $columns = array('*')); |
|
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * Fetch records from the storage based on the given |
|
| 88 | - * condition. |
|
| 89 | - * |
|
| 90 | - * @param array $conditions array of conditions |
|
| 91 | - * @param array $relations |
|
| 92 | - * @param array $sortBy |
|
| 93 | - * @param array $desc |
|
| 94 | - * @param array $columns |
|
| 95 | - * @return collection |
|
| 96 | - */ |
|
| 97 | - public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 87 | + * Fetch records from the storage based on the given |
|
| 88 | + * condition. |
|
| 89 | + * |
|
| 90 | + * @param array $conditions array of conditions |
|
| 91 | + * @param array $relations |
|
| 92 | + * @param array $sortBy |
|
| 93 | + * @param array $desc |
|
| 94 | + * @param array $columns |
|
| 95 | + * @return collection |
|
| 96 | + */ |
|
| 97 | + public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Fetch the first record fro the storage based on the given |
|
| 101 | - * condition. |
|
| 102 | - * |
|
| 103 | - * @param array $conditions array of conditions |
|
| 104 | - * @param array $relations |
|
| 105 | - * @param array $columns |
|
| 106 | - * @return object |
|
| 107 | - */ |
|
| 108 | - public function first($conditions, $relations = [], $columns = array('*')); |
|
| 99 | + /** |
|
| 100 | + * Fetch the first record fro the storage based on the given |
|
| 101 | + * condition. |
|
| 102 | + * |
|
| 103 | + * @param array $conditions array of conditions |
|
| 104 | + * @param array $relations |
|
| 105 | + * @param array $columns |
|
| 106 | + * @return object |
|
| 107 | + */ |
|
| 108 | + public function first($conditions, $relations = [], $columns = array('*')); |
|
| 109 | 109 | } |
| 110 | 110 | \ No newline at end of file |
@@ -2,17 +2,17 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Logging |
| 4 | 4 | { |
| 5 | - public function saveLog($action, $item_name, $item_type, $item_id) |
|
| 6 | - { |
|
| 7 | - if (\Core::logs() && $item_name !== 'Log') |
|
| 8 | - { |
|
| 9 | - \Core::logs()->save([ |
|
| 10 | - 'action' => $action, |
|
| 11 | - 'item_name' => $item_name, |
|
| 12 | - 'item_type' => $item_type, |
|
| 13 | - 'item_id' => $item_id, |
|
| 14 | - 'user_id' => \JWTAuth::parseToken()->authenticate()->id, |
|
| 15 | - ], false, false); |
|
| 16 | - } |
|
| 17 | - } |
|
| 5 | + public function saveLog($action, $item_name, $item_type, $item_id) |
|
| 6 | + { |
|
| 7 | + if (\Core::logs() && $item_name !== 'Log') |
|
| 8 | + { |
|
| 9 | + \Core::logs()->save([ |
|
| 10 | + 'action' => $action, |
|
| 11 | + 'item_name' => $item_name, |
|
| 12 | + 'item_type' => $item_type, |
|
| 13 | + 'item_id' => $item_id, |
|
| 14 | + 'user_id' => \JWTAuth::parseToken()->authenticate()->id, |
|
| 15 | + ], false, false); |
|
| 16 | + } |
|
| 17 | + } |
|
| 18 | 18 | } |
| 19 | 19 | \ No newline at end of file |
@@ -15,54 +15,54 @@ |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Render the given report db view. |
|
| 19 | - * |
|
| 20 | - * @param integer $id |
|
| 21 | - * @param array $relations |
|
| 22 | - * @param array $columns |
|
| 23 | - * @return object |
|
| 24 | - */ |
|
| 25 | - public function find($id, $relations = [], $columns = array('*')) |
|
| 26 | - { |
|
| 18 | + * Render the given report db view. |
|
| 19 | + * |
|
| 20 | + * @param integer $id |
|
| 21 | + * @param array $relations |
|
| 22 | + * @param array $columns |
|
| 23 | + * @return object |
|
| 24 | + */ |
|
| 25 | + public function find($id, $relations = [], $columns = array('*')) |
|
| 26 | + { |
|
| 27 | 27 | $report = call_user_func_array("{$this->getModel()}::with", array($relations))->find($id, $columns); |
| 28 | 28 | |
| 29 | - if ( ! $report) |
|
| 30 | - { |
|
| 31 | - \ErrorHandler::notFound('report'); |
|
| 32 | - } |
|
| 29 | + if ( ! $report) |
|
| 30 | + { |
|
| 31 | + \ErrorHandler::notFound('report'); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
| 35 | - { |
|
| 36 | - \ErrorHandler::noPermissions(); |
|
| 37 | - } |
|
| 34 | + if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
| 35 | + { |
|
| 36 | + \ErrorHandler::noPermissions(); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - return \DB::table($report->view_name)->get(); |
|
| 40 | - } |
|
| 39 | + return \DB::table($report->view_name)->get(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Render the given report db view based on the given |
|
| 44 | - * condition. |
|
| 45 | - * |
|
| 46 | - * @param array $conditions array of conditions |
|
| 47 | - * @param array $relations |
|
| 48 | - * @param array $colunmns |
|
| 49 | - * @return object |
|
| 50 | - */ |
|
| 51 | - public function first($conditions, $relations = [], $columns = array('*')) |
|
| 52 | - { |
|
| 42 | + /** |
|
| 43 | + * Render the given report db view based on the given |
|
| 44 | + * condition. |
|
| 45 | + * |
|
| 46 | + * @param array $conditions array of conditions |
|
| 47 | + * @param array $relations |
|
| 48 | + * @param array $colunmns |
|
| 49 | + * @return object |
|
| 50 | + */ |
|
| 51 | + public function first($conditions, $relations = [], $columns = array('*')) |
|
| 52 | + { |
|
| 53 | 53 | $conditions = $this->constructConditions($conditions); |
| 54 | 54 | $report = call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns); |
| 55 | 55 | |
| 56 | - if ( ! $report) |
|
| 57 | - { |
|
| 58 | - \ErrorHandler::notFound('report'); |
|
| 59 | - } |
|
| 56 | + if ( ! $report) |
|
| 57 | + { |
|
| 58 | + \ErrorHandler::notFound('report'); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
| 62 | - { |
|
| 63 | - \ErrorHandler::noPermissions(); |
|
| 64 | - } |
|
| 61 | + if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
| 62 | + { |
|
| 63 | + \ErrorHandler::noPermissions(); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - return \DB::table($report->view_name)->get(); |
|
| 67 | - } |
|
| 66 | + return \DB::table($report->view_name)->get(); |
|
| 67 | + } |
|
| 68 | 68 | } |