Exemplo n.º 1
0
 public function transform(\Lavalite\Message\Models\Message $message)
 {
     return ['id' => $message->getRouteKey(), 'status' => $message->status, 'star' => $message->star, 'from' => $message->from, 'to' => $message->to, 'subject' => $message->subject, 'message' => $message->message, 'read' => $message->read, 'type' => $message->type];
 }
Exemplo n.º 2
0
 /**
  * Remove the specified resource.
  *
  * @param int $id
  *
  * @return Response
  */
 public function deleteMultiple(MessageUserRequest $request, Message $message)
 {
     try {
         if (!empty($request->get('arrayIds'))) {
             $ids = $request->get('arrayIds');
             if (is_array($ids)) {
                 $t = $this->repository->deleteMultiple($ids);
             } else {
                 $t = $message->delete($ids);
             }
             return $t;
         }
         return response()->json(['message' => trans('messages.success.deleted', ['Module' => trans('message::message.name')]), 'code' => 202, 'redirect' => trans_url('/user/message/message/0')], 202);
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/user/message/message/' . $message->getRouteKey())], 400);
     }
 }
Exemplo n.º 3
0
 /**
  * Remove the message.
  *
  * @param Model   $message
  *
  * @return Response
  */
 public function destroy(MessageAdminRequest $request, Message $message)
 {
     try {
         if (!empty($request->get('arrayIds'))) {
             $ids = $request->get('arrayIds');
             $t = $this->repository->deleteMultiple($ids);
             return $t;
         } else {
             $t = $message->delete();
         }
         $this->repository->pushCriteria(new \Lavalite\Message\Repositories\Criteria\MessageAdminCriteria());
         $inbox_count = $this->repository->msgCount('Inbox');
         $trash_count = $this->repository->msgCount('Trash');
         return response()->json(['message' => trans('messages.success.deleted', ['Module' => trans('message::message.name')]), 'code' => 202, 'redirect' => trans_url('/admin/message/message/0'), 'inbox_count' => $inbox_count, 'trash_count' => $trash_count], 202);
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/message/message/' . $message->getRouteKey())], 400);
     }
 }
 /**
  * Remove the message.
  *
  * @param Request $request
  * @param Model   $message
  *
  * @return json
  */
 public function destroy(MessageAdminApiRequest $request, Message $message)
 {
     try {
         $t = $message->delete();
         return response()->json(['message' => trans('messages.success.delete', ['Module' => trans('message::message.name')]), 'code' => 2006])->setStatusCode(202, 'DESTROY_SUCCESS');
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 4006])->setStatusCode(400, 'DESTROY_ERROR');
     }
 }