当前位置: 首页>>代码示例>>PHP>>正文


PHP State::whereRaw方法代码示例

本文整理汇总了PHP中State::whereRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP State::whereRaw方法的具体用法?PHP State::whereRaw怎么用?PHP State::whereRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在State的用法示例。


在下文中一共展示了State::whereRaw方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: unlike

 public function unlike($type, $id)
 {
     $type = $this->str($type);
     $user = Auth::user();
     $like = $this->get($type, $id, $user->id);
     if ($like) {
         if ($like->delete()) {
             $object = strtolower($type);
             State::whereRaw('object=? and object_id=? and event=\'liked\'', array($object, $id))->delete();
             Notification::whereRaw('object=? and object_id=? and event=\'liked\'', array($object, $id))->get()->each(function ($notification) use($user) {
                 NotificationUser::whereRaw('notification_id=? and user_id=?', array($notification->id, $user->id))->get()->each(function ($notificationsUser) {
                     $notificationsUser->is_removed = 1;
                     $notificationsUser->save();
                 });
                 $notification->is_removed = 1;
                 $notification->save();
             });
             Notification::whereRaw('object=? and event=\'liked\' and is_removed=0 and ' . '(select count(nu.id) from notifications_users nu where nu.notification_id=notifications.id and nu.is_removed=0)=0', array($object))->get()->each(function ($notification) {
                 $notification->is_removed = 1;
                 $notification->save();
             });
             return $this->respondNoContent();
         }
     } else {
         return $this->respondNotFound('Like not found');
     }
     return $this->respondServerError();
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:28,代码来源:LikesController.php

示例2: getUserStates

 private function getUserStates($userId)
 {
     $states = array();
     State::whereRaw('owner_id = ?', array($userId))->orderBy('timestamp', 'asc')->get()->each(function ($state) use(&$states) {
         $states[] = $state;
     });
     return $states;
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:8,代码来源:Notifications.php

示例3: destroy

 /**
  * Remove the specified resource from storage.
  * DELETE /comments/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $validator = $this->validateId($id);
     if ($validator->fails()) {
         return $this->respondInsufficientPrivileges($validator->messages()->all());
     }
     $comment = Comment::find($id);
     if ($comment) {
         $post = $comment->post;
         $category = $post->category;
         if ($comment->delete()) {
             State::whereRaw('object=\'comment\' and object_id=?', array($id))->delete();
             NotificationUser::whereRaw('subject=\'comment\' and subject_id=? and is_removed=0', array($id))->get()->each(function ($notificationsUser) {
                 $notificationsUser->is_removed = 1;
                 $notificationsUser->save();
             });
             Notification::whereRaw('object=\'post\' and event=\'commented\' and is_removed=0 and ' . '(select count(nu.id) from notifications_users nu where nu.notification_id=notifications.id and nu.is_removed=0)=0')->get()->each(function ($notification) {
                 $notification->is_removed = 1;
                 $notification->save();
             });
             return $this->respondNoContent();
         }
     } else {
         return $this->respondNotFound('Comment not found');
     }
     return $this->respondServerError();
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:34,代码来源:CommentsController.php

示例4: destroy

 /**
  * Remove the specified resource from storage.
  * DELETE /posts/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $post = Post::find($id);
     if (!$post) {
         return $this->respondNotFound();
     }
     $user = Auth::user();
     if (!$user->can('Post.delete', $post)) {
         return $this->respondInsufficientPrivileges();
     }
     if ($post->delete()) {
         $category = $post->category;
         $category->updateCount('posts');
         $commentsIds = array();
         Comment::where('post_id', $id)->get()->each(function ($comment) use($commentsIds) {
             $commentsIds[] = $comment->id;
         });
         if (count($commentsIds) > 0) {
             State::whereRaw('object=\'comment\'')->whereIn('object_id', $commentsIds)->delete();
         }
         $post->comments()->delete();
         $category->updateCount('comments');
         State::whereRaw('object=\'post\' and object_id=?', array($id))->delete();
         Notification::whereRaw('object=\'post\' and object_id=? and is_removed=0', array($id))->get()->each(function ($notification) {
             NotificationUser::where('notification_id', $notification->id)->get()->each(function ($notificationsUser) {
                 $notificationsUser->is_removed = 1;
                 $notificationsUser->save();
             });
             $notification->is_removed = 1;
             $notification->save();
         });
         return $this->respondNoContent();
     }
     return $this->respondServerError();
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:42,代码来源:PostsController.php


注:本文中的State::whereRaw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。