public function transform(Moment $moment)
 {
     $image = $moment->image;
     $user = $moment->user;
     $likes = $moment->likes;
     return ['id' => $moment->id, 'text' => $moment->text, 'created_at' => $moment->created_at->toDateTimeString(), 'updated_at' => $moment->updated_at->toDateTimeString(), 'is_liked' => $moment->isUserLiked($this->request_user_id), 'like_count' => $likes->count(), 'user_id' => $user->id, 'image' => ['id' => $image->id, 'image_url' => $image->url, 'user_id' => $user->id, 'type' => $image->type]];
 }
 public function likeMoment($payload, Moment $moment)
 {
     if ($moment->isUserLiked($payload['user_id'])) {
         return array('result' => false, 'message' => 'The moment has been liked by this user!');
     }
     \DB::beginTransaction();
     try {
         $like = MomentLike::create(['moment_id' => $moment->id, 'user_id' => $payload['user_id']]);
         \DB::commit();
         return array('result' => true, 'content' => $like);
     } catch (\Exception $e) {
         \DB::rollBack();
         return array('result' => false, 'message' => $e->getMessage());
     }
 }
 public function getMoments(Request $request)
 {
     $check_result = $this->requestCheck($request, ['user_id' => 'required']);
     if (!$check_result['result']) {
         return $this->response->error($check_result['message'], 422);
     }
     $payload = $request->all();
     $moments = Moment::orderBy('created_at', 'desc')->paginate(10);
     return $this->paginator($moments, new MomentTransformer($payload['user_id']));
 }