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


PHP Note::with方法代码示例

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


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

示例1: show

 public function show($notebookId, $noteId, $versionId)
 {
     $note = Note::with(array('users' => function ($query) {
         $query->where('note_user.user_id', '=', Auth::user()->id);
     }, 'notebook' => function ($query) use(&$notebookId) {
         $query->where('id', $notebookId > 0 ? '=' : '>', $notebookId > 0 ? $notebookId : '0');
     }, 'version' => function ($query) {
     }))->where('id', '=', $noteId)->whereNull('deleted_at')->first();
     $currentVersion = $note->version()->first();
     if (is_null($currentVersion)) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array());
     }
     while (!is_null($currentVersion)) {
         if ($currentVersion->id == $versionId || $versionId == '0') {
             return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $currentVersion);
         }
         $currentVersion = $currentVersion->previous()->first();
     }
     return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array());
 }
开发者ID:Liongold,项目名称:paperwork,代码行数:20,代码来源:ApiVersionsController.php

示例2: getNoteVersionsBrief

 private function getNoteVersionsBrief($noteId)
 {
     $note = Note::with('version')->where('notes.id', '=', $noteId)->first();
     $versionsObject = $note->version()->first();
     if (is_null($versionsObject)) {
         return null;
     }
     $versionsArray = [];
     $tmp = $versionsObject;
     $isLatest = true;
     $versions = array();
     while (!is_null($tmp)) {
         $versionsArray[] = $tmp;
         $user = $tmp->user()->first();
         $versions[] = array('id' => $tmp->id, 'previous_id' => $tmp->previous_id, 'next_id' => $tmp->next_id, 'latest' => $isLatest, 'timestamp' => $tmp->created_at->getTimestamp(), 'username' => $user->firstname . ' ' . $user->lastname);
         $isLatest = false;
         $tmp = $tmp->previous()->first();
     }
     return $versions;
 }
开发者ID:netesheng,项目名称:paperwork,代码行数:20,代码来源:ApiNotesController.php

示例3: get

 public function get($argv = array())
 {
     //the version_id has to be included here or the eager load below will fail
     //also, all off the ids of the relationships have to be here also, or it will also fail
     $defaultNotesSelect = array('notes.id', 'notes.notebook_id', 'notes.created_at', 'notes.updated_at', 'notes.version_id');
     $defaultVersionsSelect = array('versions.id', 'versions.title', 'versions.content_preview', 'versions.content', 'versions.user_id');
     $defaultTagsSelect = array('tags.id', 'tags.visibility', 'tags.title');
     $defaultUsersSelect = array('users.id', 'users.firstname', 'users.lastname');
     $userId = $this->getArg($argv, 'userid');
     $id = $this->getArg($argv, 'id');
     $notebookId = $this->getArg($argv, 'notebookid');
     $data = \Note::with(array('version' => function ($query) use(&$defaultVersionsSelect, &$defaultUsersSelect) {
         $query->select($defaultVersionsSelect)->with(array('user' => function ($query) use(&$defaultUsersSelect) {
             $query->select($defaultUsersSelect);
         }));
     }, 'tags' => function ($query) use(&$defaultTagsSelect, &$userId) {
         $query->select($defaultTagsSelect)->where('visibility', '=', 1)->orWhere('tags.user_id', '=', $userId);
     }, 'users' => function ($query) use(&$defaultUsersSelect) {
         $query->select($defaultUsersSelect)->wherePivot('umask', '=', \PaperworkHelpers::UMASK_OWNER);
     }))->join('note_user', function ($join) use(&$userId) {
         $join->on('note_user.note_id', '=', 'notes.id')->where('note_user.user_id', '=', $userId)->where('note_user.umask', '>', 0);
     })->select($defaultNotesSelect);
     $idCount = count($id);
     if ($idCount > 0) {
         $data->where('notes.id', '=', $argv['id'][0]);
     }
     if ($idCount > 1) {
         for ($i = 1; $i < $idCount; $i++) {
             $data->orWhere('notes.id', '=', $argv['id'][$i]);
         }
     }
     if (isset($notebookId) && $notebookId != \PaperworkDb::DB_ALL_ID) {
         $data->where('notes.notebook_id', '=', $notebookId);
     }
     $data->whereNull('deleted_at');
     return $data->get();
 }
开发者ID:Liongold,项目名称:paperwork,代码行数:37,代码来源:PaperworkDbNoteObject.php

示例4: index

 public function index()
 {
     $loggedInUser = Auth::user()->id;
     $notes = Note::with('user')->where('user_id', '=', $loggedInUser)->orderBy('updated_at', 'desc')->paginate(10);
     return View::make('notes.index')->with('notes', $notes);
 }
开发者ID:betanotes,项目名称:betanotes.dev,代码行数:6,代码来源:NotesController.php

示例5: showNotes

 public function showNotes()
 {
     $notes = Note::with('user')->where('public_or_private', '=', 'public')->orderBy('id', 'desc')->paginate(10);
     return View::make('feed.notes')->with('notes', $notes);
 }
开发者ID:betanotes,项目名称:betanotes.dev,代码行数:5,代码来源:FeedController.php


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