本文整理汇总了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.');
}
示例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);
}