@@ -4,9 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Dingo\Api\Http; |
| 6 | 6 | use Dingo\Api\Routing\Helpers; |
| 7 | -use App\User; |
|
| 8 | 7 | use App\Notification; |
| 9 | -use App\NotificationAttrib; |
|
| 10 | 8 | use Illuminate\Http\Request; |
| 11 | 9 | |
| 12 | 10 | class NotificationController extends Controller |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $notification = Notification::find($id); |
| 41 | 41 | $enable = strpos($action, 'un') === false; |
| 42 | - if(!$enable) { |
|
| 42 | + if (!$enable) { |
|
| 43 | 43 | $action = substr($action, 2); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $notification = new Notification; |
| 69 | 69 | $notification->title = $request->title; |
| 70 | 70 | $notification->body = $request->body; |
| 71 | - $notification->checksum = hash('sha512',$request->user()->user_id.'.LOCAL.'.$request->title); |
|
| 71 | + $notification->checksum = hash('sha512', $request->user()->user_id.'.LOCAL.'.$request->title); |
|
| 72 | 72 | $notification->source = $request->user()->user_id; |
| 73 | 73 | if ($notification->save()) |
| 74 | 74 | { |
@@ -27,8 +27,7 @@ discard block |
||
| 27 | 27 | if ($type === 'archive') |
| 28 | 28 | { |
| 29 | 29 | $notifications = Notification::IsArchived($request)->get(); |
| 30 | - } |
|
| 31 | - else { |
|
| 30 | + } else { |
|
| 32 | 31 | $notifications = Notification::IsUnread()->get(); |
| 33 | 32 | } |
| 34 | 33 | return $notifications; |
@@ -45,15 +44,13 @@ discard block |
||
| 45 | 44 | |
| 46 | 45 | if ($action == 'read') { |
| 47 | 46 | $result = $notification->markRead($enable); |
| 48 | - } |
|
| 49 | - elseif ($action == 'sticky') { |
|
| 47 | + } elseif ($action == 'sticky') { |
|
| 50 | 48 | $result = $notification->markSticky(false); |
| 51 | 49 | } |
| 52 | 50 | |
| 53 | 51 | if ($result === false) { |
| 54 | 52 | return $this->response->errorInternal(); |
| 55 | - } |
|
| 56 | - else { |
|
| 53 | + } else { |
|
| 57 | 54 | return $this->response->array(array('statusText' => 'OK')); |
| 58 | 55 | } |
| 59 | 56 | } |
@@ -73,8 +70,7 @@ discard block |
||
| 73 | 70 | if ($notification->save()) |
| 74 | 71 | { |
| 75 | 72 | return $this->response->array(array('statusText' => 'OK')); |
| 76 | - } |
|
| 77 | - else { |
|
| 73 | + } else { |
|
| 78 | 74 | return $this->response->errorInternal(); |
| 79 | 75 | } |
| 80 | 76 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * Update a notifications status. |
| 46 | 46 | * |
| 47 | - * @return \Illuminate\Http\Response |
|
| 47 | + * @return \Illuminate\Http\JsonResponse |
|
| 48 | 48 | */ |
| 49 | 49 | public function update($id, $action) |
| 50 | 50 | { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * Create a new notification |
| 57 | 57 | * |
| 58 | - * @return \Illuminate\Http\Response |
|
| 58 | + * @return \Illuminate\Http\JsonResponse |
|
| 59 | 59 | */ |
| 60 | 60 | public function create(Request $request) |
| 61 | 61 | { |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | |
| 71 | 71 | public function scopeLimit($query) |
| 72 | 72 | { |
| 73 | - return $query->select('notifications.*','key', 'users.username'); |
|
| 73 | + return $query->select('notifications.*', 'key', 'users.username'); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | public function scopeSource($query) |