當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Annotation::where方法代碼示例

本文整理匯總了PHP中Annotation::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Annotation::where方法的具體用法?PHP Annotation::where怎麽用?PHP Annotation::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Annotation的用法示例。


在下文中一共展示了Annotation::where方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $doc_id = $this->argument('doc_id');
     $filename = $this->argument('filename');
     $doc = Doc::where('id', $doc_id)->first();
     $this->info("Exporting activity for " . $doc->title);
     $annotations = Annotation::where('doc_id', $this->argument('doc_id'))->with('user')->with('comments')->get();
     $comments = Comment::where('doc_id', $this->argument('doc_id'))->with('user')->get();
     $headers = array("Created At", "Link", "Display Name", "Full Name", "Email", "Type", "Quote", "Text");
     $toExport = array();
     foreach ($annotations as $annotation) {
         $annotationArray = array();
         $annotationArray['date'] = $annotation->created_at;
         $annotationArray['link'] = URL::to('/') . $annotation->uri . '#annotation_' . $annotation->id;
         $annotationArray['display_name'] = $annotation->user->fname . " " . substr($annotation->user->lname, 0, 1);
         $annotationArray['full_name'] = $annotation->user->fname . " " . $annotation->user->lname;
         $annotationArray['email'] = $annotation->user->email;
         $annotationArray['type'] = 'Annotation';
         $annotationArray['quote'] = $annotation->quote;
         $annotationArray['text'] = $annotation->text;
         array_push($toExport, $annotationArray);
         foreach ($annotation->comments as $comment) {
             $user = User::find($comment->user_id);
             $commentArray = array();
             $commentArray['date'] = $comment->created_at;
             $commentArray['link'] = "";
             $commentArray['display_name'] = $user->fname . " " . substr($user->lname, 0, 1);
             $commentArray['full_name'] = $user->fname . " " . $user->lname;
             $commentArray['email'] = $user->email;
             $commentArray['type'] = "Annotation Comment";
             $commentArray['quote'] = "";
             $commentArray['text'] = $comment->text;
             array_push($toExport, $commentArray);
         }
     }
     foreach ($comments as $comment) {
         $commentArray = array();
         $commentArray['date'] = $comment->created_at;
         $commentArray['link'] = "";
         $commentArray['display_name'] = $comment->user->fname . " " . substr($comment->user->lname, 0, 1);
         $commentArray['full_name'] = $comment->user->fname . " " . $comment->user->lname;
         $commentArray['email'] = $comment->user->email;
         $commentArray['type'] = $comment->parent_id === null ? "Comment" : "Sub-comment";
         $commentArray['quote'] = "";
         $commentArray['text'] = $comment->text;
         array_push($toExport, $commentArray);
     }
     $this->info('Saving export to ' . $filename);
     $fp = fopen($filename, 'w');
     fputcsv($fp, $headers);
     foreach ($toExport as $row) {
         fputcsv($fp, $row);
     }
     fclose($fp);
     $this->info('Done.');
 }
開發者ID:iaincollins,項目名稱:madison,代碼行數:61,代碼來源:ActivityExport.php

示例2: postComments

 public function postComments($docId, $annotationId)
 {
     $comment = Input::get('comment');
     $annotation = Annotation::where('doc_id', '=', $docId)->where('id', '=', $annotationId)->first();
     $annotation->link = $annotation->getLink();
     $annotation->type = 'annotation';
     $result = $annotation->addOrUpdateComment($comment);
     // TODO: Hack to allow notification events.  Needs cleaned up.
     $result->doc_id = $docId;
     $result->link = $result->getLink($docId);
     Event::fire(MadisonEvent::DOC_SUBCOMMENT, array('subcomment' => $result, 'parent' => $annotation));
     return Response::json($result);
 }
開發者ID:sethetter,項目名稱:madison,代碼行數:13,代碼來源:AnnotationApiController.php


注:本文中的Annotation::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。