@@ -7,67 +7,67 @@ |
||
7 | 7 | |
8 | 8 | class Handler extends ExceptionHandler |
9 | 9 | { |
10 | - /** |
|
11 | - * A list of the exception types that are not reported. |
|
12 | - * |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - protected $dontReport = [ |
|
16 | - \League\OAuth2\Server\Exception\OAuthServerException::class, |
|
17 | - ]; |
|
10 | + /** |
|
11 | + * A list of the exception types that are not reported. |
|
12 | + * |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + protected $dontReport = [ |
|
16 | + \League\OAuth2\Server\Exception\OAuthServerException::class, |
|
17 | + ]; |
|
18 | 18 | |
19 | - /** |
|
20 | - * A list of the inputs that are never flashed for validation exceptions. |
|
21 | - * |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $dontFlash = [ |
|
25 | - 'password', |
|
26 | - 'password_confirmation', |
|
27 | - ]; |
|
19 | + /** |
|
20 | + * A list of the inputs that are never flashed for validation exceptions. |
|
21 | + * |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $dontFlash = [ |
|
25 | + 'password', |
|
26 | + 'password_confirmation', |
|
27 | + ]; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Report or log an exception. |
|
31 | - * |
|
32 | - * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|
33 | - * |
|
34 | - * @param \Exception $exception |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - public function report(Exception $exception) |
|
38 | - { |
|
39 | - parent::report($exception); |
|
40 | - } |
|
29 | + /** |
|
30 | + * Report or log an exception. |
|
31 | + * |
|
32 | + * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|
33 | + * |
|
34 | + * @param \Exception $exception |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + public function report(Exception $exception) |
|
38 | + { |
|
39 | + parent::report($exception); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Render an exception into an HTTP response. |
|
44 | - * |
|
45 | - * @param \Illuminate\Http\Request $request |
|
46 | - * @param \Exception $exception |
|
47 | - * @return \Illuminate\Http\Response |
|
48 | - */ |
|
49 | - public function render($request, Exception $exception) |
|
50 | - { |
|
51 | - if ($request->wantsJson()) { |
|
52 | - if ($exception instanceof \Illuminate\Auth\AuthenticationException) { |
|
53 | - \ErrorHandler::unAuthorized(); |
|
54 | - } |
|
55 | - if ($exception instanceof \Illuminate\Database\QueryException) { |
|
56 | - \ErrorHandler::dbQueryError(); |
|
57 | - } elseif ($exception instanceof \predis\connection\connectionexception) { |
|
58 | - \ErrorHandler::redisNotRunning(); |
|
59 | - } elseif ($exception instanceof \GuzzleHttp\Exception\ClientException) { |
|
60 | - \ErrorHandler::connectionError(); |
|
61 | - } elseif ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { |
|
62 | - $errors = $exception->getStatusCode() === 404 ? 'not found' : $exception->getMessage(); |
|
63 | - return \Response::json(['errors' => [$errors]], $exception->getStatusCode()); |
|
64 | - } elseif ($exception instanceof \Illuminate\Validation\ValidationException) { |
|
65 | - return \Response::json(['errors' => $exception->errors()], 422); |
|
66 | - } elseif (! $exception instanceof \Symfony\Component\ErrorHandler\Error\FatalError) { |
|
67 | - return parent::render($request, $exception); |
|
68 | - } |
|
69 | - } |
|
42 | + /** |
|
43 | + * Render an exception into an HTTP response. |
|
44 | + * |
|
45 | + * @param \Illuminate\Http\Request $request |
|
46 | + * @param \Exception $exception |
|
47 | + * @return \Illuminate\Http\Response |
|
48 | + */ |
|
49 | + public function render($request, Exception $exception) |
|
50 | + { |
|
51 | + if ($request->wantsJson()) { |
|
52 | + if ($exception instanceof \Illuminate\Auth\AuthenticationException) { |
|
53 | + \ErrorHandler::unAuthorized(); |
|
54 | + } |
|
55 | + if ($exception instanceof \Illuminate\Database\QueryException) { |
|
56 | + \ErrorHandler::dbQueryError(); |
|
57 | + } elseif ($exception instanceof \predis\connection\connectionexception) { |
|
58 | + \ErrorHandler::redisNotRunning(); |
|
59 | + } elseif ($exception instanceof \GuzzleHttp\Exception\ClientException) { |
|
60 | + \ErrorHandler::connectionError(); |
|
61 | + } elseif ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { |
|
62 | + $errors = $exception->getStatusCode() === 404 ? 'not found' : $exception->getMessage(); |
|
63 | + return \Response::json(['errors' => [$errors]], $exception->getStatusCode()); |
|
64 | + } elseif ($exception instanceof \Illuminate\Validation\ValidationException) { |
|
65 | + return \Response::json(['errors' => $exception->errors()], 422); |
|
66 | + } elseif (! $exception instanceof \Symfony\Component\ErrorHandler\Error\FatalError) { |
|
67 | + return parent::render($request, $exception); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - return parent::render($request, $exception); |
|
72 | - } |
|
71 | + return parent::render($request, $exception); |
|
72 | + } |
|
73 | 73 | } |
@@ -13,27 +13,27 @@ |
||
13 | 13 | |
14 | 14 | Route::group(['prefix' => 'notifications'], function () { |
15 | 15 | |
16 | - Route::group(['prefix' => 'notifications'], function () { |
|
16 | + Route::group(['prefix' => 'notifications'], function () { |
|
17 | 17 | |
18 | - Route::get('list/{perPage?}', 'NotificationsController@list'); |
|
19 | - Route::get('unread/{perPage?}', 'NotificationsController@unread'); |
|
20 | - Route::get('markAsRead/{id}', 'NotificationsController@markAsRead'); |
|
21 | - Route::get('markAllAsRead', 'NotificationsController@markAllAsRead'); |
|
22 | - }); |
|
18 | + Route::get('list/{perPage?}', 'NotificationsController@list'); |
|
19 | + Route::get('unread/{perPage?}', 'NotificationsController@unread'); |
|
20 | + Route::get('markAsRead/{id}', 'NotificationsController@markAsRead'); |
|
21 | + Route::get('markAllAsRead', 'NotificationsController@markAllAsRead'); |
|
22 | + }); |
|
23 | 23 | |
24 | - Route::group(['prefix' => 'push_notification_devices'], function () { |
|
24 | + Route::group(['prefix' => 'push_notification_devices'], function () { |
|
25 | 25 | |
26 | - Route::get('list/{sortBy?}/{desc?}', 'PushNotificationDevicesController@index'); |
|
27 | - Route::get('find/{id}', 'PushNotificationDevicesController@find'); |
|
28 | - Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationDevicesController@search'); |
|
29 | - Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationDevicesController@paginate'); |
|
30 | - Route::get('delete/{id}', 'PushNotificationDevicesController@delete'); |
|
31 | - Route::get('restore/{id}', 'PushNotificationDevicesController@restore'); |
|
32 | - Route::post('first', 'PushNotificationDevicesController@first'); |
|
33 | - Route::post('findby/{sortBy?}/{desc?}', 'PushNotificationDevicesController@findby'); |
|
34 | - Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationDevicesController@paginateby'); |
|
35 | - Route::post('save', 'PushNotificationDevicesController@save'); |
|
36 | - Route::post('deleted/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationDevicesController@deleted'); |
|
37 | - Route::post('register/device', 'PushNotificationDevicesController@registerDevice'); |
|
38 | - }); |
|
26 | + Route::get('list/{sortBy?}/{desc?}', 'PushNotificationDevicesController@index'); |
|
27 | + Route::get('find/{id}', 'PushNotificationDevicesController@find'); |
|
28 | + Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationDevicesController@search'); |
|
29 | + Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationDevicesController@paginate'); |
|
30 | + Route::get('delete/{id}', 'PushNotificationDevicesController@delete'); |
|
31 | + Route::get('restore/{id}', 'PushNotificationDevicesController@restore'); |
|
32 | + Route::post('first', 'PushNotificationDevicesController@first'); |
|
33 | + Route::post('findby/{sortBy?}/{desc?}', 'PushNotificationDevicesController@findby'); |
|
34 | + Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationDevicesController@paginateby'); |
|
35 | + Route::post('save', 'PushNotificationDevicesController@save'); |
|
36 | + Route::post('deleted/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationDevicesController@deleted'); |
|
37 | + Route::post('register/device', 'PushNotificationDevicesController@registerDevice'); |
|
38 | + }); |
|
39 | 39 | }); |
@@ -5,31 +5,31 @@ |
||
5 | 5 | |
6 | 6 | class PushNotificationsDevices extends Migration |
7 | 7 | { |
8 | - /** |
|
9 | - * Run the migrations. |
|
10 | - * |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function up() |
|
14 | - { |
|
15 | - Schema::create('push_notification_devices', function (Blueprint $table) { |
|
16 | - $table->increments('id'); |
|
17 | - $table->string('device_token'); |
|
18 | - $table->integer('user_id'); |
|
19 | - $table->text('access_token')->nullable(); |
|
20 | - $table->unique(array('device_token', 'user_id')); |
|
21 | - $table->softDeletes(); |
|
22 | - $table->timestamps(); |
|
23 | - }); |
|
24 | - } |
|
8 | + /** |
|
9 | + * Run the migrations. |
|
10 | + * |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function up() |
|
14 | + { |
|
15 | + Schema::create('push_notification_devices', function (Blueprint $table) { |
|
16 | + $table->increments('id'); |
|
17 | + $table->string('device_token'); |
|
18 | + $table->integer('user_id'); |
|
19 | + $table->text('access_token')->nullable(); |
|
20 | + $table->unique(array('device_token', 'user_id')); |
|
21 | + $table->softDeletes(); |
|
22 | + $table->timestamps(); |
|
23 | + }); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Reverse the migrations. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function down() |
|
32 | - { |
|
33 | - Schema::dropIfExists('push_notifications_devices'); |
|
34 | - } |
|
26 | + /** |
|
27 | + * Reverse the migrations. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function down() |
|
32 | + { |
|
33 | + Schema::dropIfExists('push_notifications_devices'); |
|
34 | + } |
|
35 | 35 | } |
@@ -6,21 +6,21 @@ |
||
6 | 6 | |
7 | 7 | class Notification extends JsonResource |
8 | 8 | { |
9 | - /** |
|
10 | - * Transform the resource into an array. |
|
11 | - * |
|
12 | - * @param \Illuminate\Http\Request $request |
|
13 | - * @return array |
|
14 | - */ |
|
15 | - public function toArray($request) |
|
16 | - { |
|
17 | - return [ |
|
18 | - 'id' => $this->id, |
|
19 | - 'type' => $this->type, |
|
20 | - 'data' => $this->data, |
|
21 | - 'readAt' => $this->read_at, |
|
22 | - 'createdAt' => $this->created_at, |
|
23 | - 'updatedAt' => $this->updated_at, |
|
24 | - ]; |
|
25 | - } |
|
9 | + /** |
|
10 | + * Transform the resource into an array. |
|
11 | + * |
|
12 | + * @param \Illuminate\Http\Request $request |
|
13 | + * @return array |
|
14 | + */ |
|
15 | + public function toArray($request) |
|
16 | + { |
|
17 | + return [ |
|
18 | + 'id' => $this->id, |
|
19 | + 'type' => $this->type, |
|
20 | + 'data' => $this->data, |
|
21 | + 'readAt' => $this->read_at, |
|
22 | + 'createdAt' => $this->created_at, |
|
23 | + 'updatedAt' => $this->updated_at, |
|
24 | + ]; |
|
25 | + } |
|
26 | 26 | } |
@@ -7,22 +7,22 @@ |
||
7 | 7 | |
8 | 8 | class PushNotificationDevice extends JsonResource |
9 | 9 | { |
10 | - /** |
|
11 | - * Transform the resource into an array. |
|
12 | - * |
|
13 | - * @param \Illuminate\Http\Request $request |
|
14 | - * @return array |
|
15 | - */ |
|
16 | - public function toArray($request) |
|
17 | - { |
|
18 | - return [ |
|
19 | - 'id' => $this->id, |
|
20 | - 'deviceToken' => $this->device_token, |
|
21 | - 'accessToken' => $this->access_token, |
|
22 | - 'user' => new UserResource($this->whenLoaded('user')), |
|
23 | - 'timeZone' => $this->time_zone, |
|
24 | - 'createdAt' => $this->created_at, |
|
25 | - 'updatedAt' => $this->updated_at, |
|
26 | - ]; |
|
27 | - } |
|
10 | + /** |
|
11 | + * Transform the resource into an array. |
|
12 | + * |
|
13 | + * @param \Illuminate\Http\Request $request |
|
14 | + * @return array |
|
15 | + */ |
|
16 | + public function toArray($request) |
|
17 | + { |
|
18 | + return [ |
|
19 | + 'id' => $this->id, |
|
20 | + 'deviceToken' => $this->device_token, |
|
21 | + 'accessToken' => $this->access_token, |
|
22 | + 'user' => new UserResource($this->whenLoaded('user')), |
|
23 | + 'timeZone' => $this->time_zone, |
|
24 | + 'createdAt' => $this->created_at, |
|
25 | + 'updatedAt' => $this->updated_at, |
|
26 | + ]; |
|
27 | + } |
|
28 | 28 | } |
@@ -9,47 +9,47 @@ |
||
9 | 9 | |
10 | 10 | class PushNotificationDevicesController extends BaseApiController |
11 | 11 | { |
12 | - /** |
|
13 | - * List of all route actions that the base api controller |
|
14 | - * will skip permissions check for them. |
|
15 | - * @var array |
|
16 | - */ |
|
17 | - protected $skipPermissionCheck = ['registerDevice']; |
|
12 | + /** |
|
13 | + * List of all route actions that the base api controller |
|
14 | + * will skip permissions check for them. |
|
15 | + * @var array |
|
16 | + */ |
|
17 | + protected $skipPermissionCheck = ['registerDevice']; |
|
18 | 18 | |
19 | - /** |
|
20 | - * The validations rules used by the base api controller |
|
21 | - * to check before add. |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $validationRules = [ |
|
25 | - 'device_token' => 'required|string|max:255', |
|
26 | - 'user_id' => 'required|exists:users,id' |
|
27 | - ]; |
|
19 | + /** |
|
20 | + * The validations rules used by the base api controller |
|
21 | + * to check before add. |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $validationRules = [ |
|
25 | + 'device_token' => 'required|string|max:255', |
|
26 | + 'user_id' => 'required|exists:users,id' |
|
27 | + ]; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Init new object. |
|
31 | - * |
|
32 | - * @param PushNotificationDeviceRepository $repo |
|
33 | - * @param CoreConfig $config |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config) |
|
37 | - { |
|
38 | - parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\PushNotificationDevice'); |
|
39 | - } |
|
29 | + /** |
|
30 | + * Init new object. |
|
31 | + * |
|
32 | + * @param PushNotificationDeviceRepository $repo |
|
33 | + * @param CoreConfig $config |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config) |
|
37 | + { |
|
38 | + parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\PushNotificationDevice'); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Register the given device to the logged in user. |
|
43 | - * |
|
44 | - * @param \Illuminate\Http\Request $request |
|
45 | - * @return \Illuminate\Http\Response |
|
46 | - */ |
|
47 | - public function registerDevice(Request $request) |
|
48 | - { |
|
49 | - $this->validate($request, [ |
|
50 | - 'device_token' => 'required|string|max:255' |
|
51 | - ]); |
|
41 | + /** |
|
42 | + * Register the given device to the logged in user. |
|
43 | + * |
|
44 | + * @param \Illuminate\Http\Request $request |
|
45 | + * @return \Illuminate\Http\Response |
|
46 | + */ |
|
47 | + public function registerDevice(Request $request) |
|
48 | + { |
|
49 | + $this->validate($request, [ |
|
50 | + 'device_token' => 'required|string|max:255' |
|
51 | + ]); |
|
52 | 52 | |
53 | - return new $this->modelResource($this->repo->registerDevice($request->all())); |
|
54 | - } |
|
53 | + return new $this->modelResource($this->repo->registerDevice($request->all())); |
|
54 | + } |
|
55 | 55 | } |
@@ -9,65 +9,65 @@ |
||
9 | 9 | |
10 | 10 | class NotificationsController extends BaseApiController |
11 | 11 | { |
12 | - /** |
|
13 | - * List of all route actions that the base api controller |
|
14 | - * will skip permissions check for them. |
|
15 | - * @var array |
|
16 | - */ |
|
17 | - protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'list', 'unread']; |
|
12 | + /** |
|
13 | + * List of all route actions that the base api controller |
|
14 | + * will skip permissions check for them. |
|
15 | + * @var array |
|
16 | + */ |
|
17 | + protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'list', 'unread']; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Init new object. |
|
21 | - * |
|
22 | - * @param NotificationRepository $repo |
|
23 | - * @param CoreConfig $config |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function __construct(NotificationRepository $repo, CoreConfig $config) |
|
27 | - { |
|
28 | - parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\Notification'); |
|
29 | - } |
|
19 | + /** |
|
20 | + * Init new object. |
|
21 | + * |
|
22 | + * @param NotificationRepository $repo |
|
23 | + * @param CoreConfig $config |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function __construct(NotificationRepository $repo, CoreConfig $config) |
|
27 | + { |
|
28 | + parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\Notification'); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Retrieve all notifications of the logged in user. |
|
33 | - * |
|
34 | - * @param integer $perPage Number of rows per page default all data. |
|
35 | - * @return \Illuminate\Http\Response |
|
36 | - */ |
|
37 | - public function list($perPage = 0) |
|
38 | - { |
|
39 | - return $this->modelResource::collection($this->repo->list($perPage)); |
|
40 | - } |
|
31 | + /** |
|
32 | + * Retrieve all notifications of the logged in user. |
|
33 | + * |
|
34 | + * @param integer $perPage Number of rows per page default all data. |
|
35 | + * @return \Illuminate\Http\Response |
|
36 | + */ |
|
37 | + public function list($perPage = 0) |
|
38 | + { |
|
39 | + return $this->modelResource::collection($this->repo->list($perPage)); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Retrieve unread notifications of the logged in user. |
|
44 | - * |
|
45 | - * @param integer $perPage Number of rows per page default all data. |
|
46 | - * @return \Illuminate\Http\Response |
|
47 | - */ |
|
48 | - public function unread($perPage = 0) |
|
49 | - { |
|
50 | - return $this->modelResource::collection($this->repo->unread($perPage)); |
|
51 | - } |
|
42 | + /** |
|
43 | + * Retrieve unread notifications of the logged in user. |
|
44 | + * |
|
45 | + * @param integer $perPage Number of rows per page default all data. |
|
46 | + * @return \Illuminate\Http\Response |
|
47 | + */ |
|
48 | + public function unread($perPage = 0) |
|
49 | + { |
|
50 | + return $this->modelResource::collection($this->repo->unread($perPage)); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Mark the notification as read. |
|
55 | - * |
|
56 | - * @param integer $id Id of the notification. |
|
57 | - * @return \Illuminate\Http\Response |
|
58 | - */ |
|
59 | - public function markAsRead($id) |
|
60 | - { |
|
61 | - return new GeneralResource($this->repo->markAsRead($id)); |
|
62 | - } |
|
53 | + /** |
|
54 | + * Mark the notification as read. |
|
55 | + * |
|
56 | + * @param integer $id Id of the notification. |
|
57 | + * @return \Illuminate\Http\Response |
|
58 | + */ |
|
59 | + public function markAsRead($id) |
|
60 | + { |
|
61 | + return new GeneralResource($this->repo->markAsRead($id)); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Mark all notifications as read. |
|
66 | - * |
|
67 | - * @return \Illuminate\Http\Response |
|
68 | - */ |
|
69 | - public function markAllAsRead() |
|
70 | - { |
|
71 | - return new GeneralResource($this->repo->markAllAsRead()); |
|
72 | - } |
|
64 | + /** |
|
65 | + * Mark all notifications as read. |
|
66 | + * |
|
67 | + * @return \Illuminate\Http\Response |
|
68 | + */ |
|
69 | + public function markAllAsRead() |
|
70 | + { |
|
71 | + return new GeneralResource($this->repo->markAllAsRead()); |
|
72 | + } |
|
73 | 73 | } |
@@ -4,28 +4,28 @@ |
||
4 | 4 | |
5 | 5 | class SettingRepository extends AbstractRepository |
6 | 6 | { |
7 | - /** |
|
8 | - * Return the model full namespace. |
|
9 | - * |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - protected function getModel() |
|
13 | - { |
|
14 | - return 'App\Modules\Core\Setting'; |
|
15 | - } |
|
7 | + /** |
|
8 | + * Return the model full namespace. |
|
9 | + * |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + protected function getModel() |
|
13 | + { |
|
14 | + return 'App\Modules\Core\Setting'; |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * Save list of settings. |
|
19 | - * |
|
20 | - * @param array $data |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function saveMany(array $data) |
|
24 | - { |
|
25 | - \DB::transaction(function () use ($data) { |
|
26 | - foreach ($data as $value) { |
|
27 | - $this->save($value); |
|
28 | - } |
|
29 | - }); |
|
30 | - } |
|
17 | + /** |
|
18 | + * Save list of settings. |
|
19 | + * |
|
20 | + * @param array $data |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function saveMany(array $data) |
|
24 | + { |
|
25 | + \DB::transaction(function () use ($data) { |
|
26 | + foreach ($data as $value) { |
|
27 | + $this->save($value); |
|
28 | + } |
|
29 | + }); |
|
30 | + } |
|
31 | 31 | } |
@@ -6,37 +6,37 @@ |
||
6 | 6 | class Setting extends Model |
7 | 7 | { |
8 | 8 | |
9 | - use SoftDeletes; |
|
10 | - protected $table = 'settings'; |
|
11 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | - protected $hidden = ['deleted_at']; |
|
13 | - protected $guarded = ['id', 'key']; |
|
14 | - protected $fillable = ['name', 'value']; |
|
15 | - public $searchable = ['name', 'value', 'key']; |
|
9 | + use SoftDeletes; |
|
10 | + protected $table = 'settings'; |
|
11 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | + protected $hidden = ['deleted_at']; |
|
13 | + protected $guarded = ['id', 'key']; |
|
14 | + protected $fillable = ['name', 'value']; |
|
15 | + public $searchable = ['name', 'value', 'key']; |
|
16 | 16 | |
17 | - public function getCreatedAtAttribute($value) |
|
18 | - { |
|
19 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | - } |
|
17 | + public function getCreatedAtAttribute($value) |
|
18 | + { |
|
19 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | + } |
|
21 | 21 | |
22 | - public function getUpdatedAtAttribute($value) |
|
23 | - { |
|
24 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | - } |
|
22 | + public function getUpdatedAtAttribute($value) |
|
23 | + { |
|
24 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | + } |
|
26 | 26 | |
27 | - public function getDeletedAtAttribute($value) |
|
28 | - { |
|
29 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | - } |
|
27 | + public function getDeletedAtAttribute($value) |
|
28 | + { |
|
29 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | + } |
|
31 | 31 | |
32 | - public function newCollection(array $models = []) |
|
33 | - { |
|
34 | - return parent::newCollection($models)->keyBy('key'); |
|
35 | - } |
|
32 | + public function newCollection(array $models = []) |
|
33 | + { |
|
34 | + return parent::newCollection($models)->keyBy('key'); |
|
35 | + } |
|
36 | 36 | |
37 | - public static function boot() |
|
38 | - { |
|
39 | - parent::boot(); |
|
40 | - Setting::observe(\App::make('App\Modules\Core\ModelObservers\SettingsObserver')); |
|
41 | - } |
|
37 | + public static function boot() |
|
38 | + { |
|
39 | + parent::boot(); |
|
40 | + Setting::observe(\App::make('App\Modules\Core\ModelObservers\SettingsObserver')); |
|
41 | + } |
|
42 | 42 | } |