本文整理汇总了PHP中Note::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Note::find方法的具体用法?PHP Note::find怎么用?PHP Note::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Note
的用法示例。
在下文中一共展示了Note::find方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$note = Note::find($id);
$note->delete();
Session::flash('message', 'Successfully deleted the Note you have selected!');
return Redirect::to('notes');
}
示例2: hasSharesDebt
public function hasSharesDebt($id = null)
{
$options = array('conditions' => array('Condo.' . $this->primaryKey => $id));
$this->contain('Fraction');
$condo = $this->find('first', $options);
$fractions = Set::extract('/Fraction/id', $condo);
$Note = new Note();
return $hasSharesDebt = $Note->find('count', array('conditions' => array('Note.fraction_id' => $fractions, 'Note.note_type_id =' => 2, 'Note.note_status_id <' => 3, 'Note.document_date < NOW()')));
}
示例3: createOrGetTags
public static function createOrGetTags($tagsArray, $noteId, $noteUmask)
{
$tagsPublicPrefixCharacter = Config::get('paperwork.tagsPublicPrefixCharacter')[0];
$createdOrFoundIds = array();
if (is_null($tagsArray)) {
return null;
}
$userId = Auth::user()->id;
foreach ($tagsArray as $tagItem) {
$tagTitle = '';
$tagVisibility = 0;
if ($tagItem[0] === $tagsPublicPrefixCharacter) {
$tagTitle = strtolower(substr($tagItem, 1));
$tagVisibility = 1;
$tag = Tag::where('tags.title', '=', $tagTitle)->where('tags.visibility', '=', $tagVisibility)->first();
} else {
$tagTitle = strtolower($tagItem);
$tagVisibility = 0;
$tag = Tag::where('tags.title', '=', $tagTitle)->where('tags.visibility', '=', $tagVisibility)->where('tags.user_id', '=', $userId)->first();
}
// ->where('tags.title', '=', $tagTitle)
// ->where('tags.visibility', '=', $tagVisibility)
// ->select('tags.id')
// ->first();
if (is_null($tag) && ($tagVisibility == 0 || $tagVisibility == 1 && $noteUmask > PaperworkHelpers::UMASK_READONLY)) {
$newTag = new Tag();
$newTag->title = $tagTitle;
$newTag->visibility = $tagVisibility;
$newTag->user_id = $userId;
$newTag->save();
//$newTag->users()->attach(Auth::user()->id);
$createdOrFoundIds[] = $newTag->id;
} else {
if ($tagVisibility == 0 || $tagVisibility == 1 && $noteUmask > PaperworkHelpers::UMASK_READONLY) {
/*if(is_null($tag->users()->where('users.id', '=', Auth::user()->id)->first())) {
$tag->users()->attach(Auth::user()->id);
}*/
$createdOrFoundIds[] = $tag->id;
}
}
}
//we need to add the other user's private tags to the list.
$addtags = Note::find($noteId)->tags()->where('tags.visibility', '=', 0)->where('tags.user_id', '!=', $userId)->get();
foreach ($addtags as $addtag) {
$createdOrFoundIds[] = $addtag->id;
}
//if the user is not writer, he cannot change public tags.
if ($noteUmask < PaperworkHelpers::UMASK_READWRITE) {
$addpubtags = Note::find($noteId)->tags()->where('tags.visibility', '=', 1)->get();
foreach ($addpubtags as $addtag) {
$createdOrFoundIds[] = $addtag->id;
}
}
return $createdOrFoundIds;
}
示例4: showeditcommentnote
public function showeditcommentnote($id, $commentid)
{
$comment = Notecom::find($commentid);
$note = Note::find($id);
if (Auth::user()->id != $comment->collaborator_id) {
if (Auth::user()->id != $note->user_id) {
Session::flash('errorMessage', 'You are not authorized to edit this comment!');
return Redirect::action('NotesController@show', array($id));
}
}
return View::make('/collaboration/editcommentnote')->with('comment', $comment)->with('note', $note);
}
示例5: update
public function update()
{
if (isset($this->params()->note['post_id'])) {
$note = new Note(['post_id' => $this->params()->note['post_id']]);
} else {
$note = Note::find($this->params()->id);
}
if ($note->is_locked()) {
$this->respond_to_error("Post is locked", array('post#show', 'id' => $note->post_id), ['status' => 422]);
return;
}
$note->assignAttributes($this->params()->note);
$note->user_id = current_user()->id;
$note->ip_addr = $this->request()->remoteIp();
# iTODO:
if ($note->save()) {
$this->respond_to_success("Note updated", '#index', ['api' => ['new_id' => $note->id, 'old_id' => (int) $this->params()->id, 'formatted_body' => $note->formatted_body()]]);
// ActionController::Base.helpers.sanitize(note.formatted_body)]]);
} else {
$this->respond_to_error($note, ['post#show', 'id' => $note->post_id]);
}
}
示例6: destroy
public function destroy($id)
{
$note = Note::find($id);
if (Auth::user()->id != $note->user_id) {
Session::flash('errorMessage', 'You are not authorized to destroy this note!');
return Redirect::action('NotesController@index');
}
$notescomments = DB::table('notecoms')->where('note_id', $id);
$notescomments->delete();
$note->delete();
return Redirect::action('NotesController@index');
}
示例7: setNoteData
private function setNoteData()
{
if (isset($this->phkRequestData['note_id']) && !isset($this->phkRequestData['note_text'])) {
App::import("Model", "Note");
$note = new Note();
$result = $note->find("first", array('conditions' => array('Note.id' => $this->phkRequestData['note_id'])));
if (count($result)) {
$this->phkRequestData['note_id'] = $result['Note']['id'];
$this->phkRequestData['note_text'] = $result['Note']['document'];
$this->phkRequestData['owner_id'] = $result['Note']['entity_id'];
$this->phkRequestData['fraction_id'] = $result['Note']['fraction_id'];
}
}
}
示例8: destroy
public function destroy($id)
{
$note = Note::find($id);
$note->delete();
return Response::json(['note' => $note, 'message' => 'Note Deleted']);
}
示例9: search
public function search()
{
if (empty($_GET['query'])) {
exit;
}
# TODO
$config = Config::current();
if ($config->clean_urls and substr_count($_SERVER['REQUEST_URI'], "?") and !substr_count($_SERVER['REQUEST_URI'], "%2F")) {
# Searches with / and clean URLs = server 404
redirect("search/" . urlencode($_GET['query']) . "/");
}
if (empty($_GET['query'])) {
return Flash::warning(__("Please enter a search term."));
}
list($where, $params) = keywords($_GET['query'], "name LIKE :query OR url LIKE :query", "extensions");
$extensions = Extension::find(array("placeholders" => true, "where" => $where, "params" => $params));
list($where, $params) = keywords($_GET['query'], "description LIKE :query OR tags LIKE :query", "versions");
$versions = Version::find(array("placeholders" => true, "where" => $where, "params" => $params));
list($where, $params) = keywords($_GET['query'], "body LIKE :query", "notes");
$notes = Note::find(array("placeholders" => true, "where" => $where, "params" => $params));
$this->display("extend/search", array("extensions" => new Paginator($extensions, 25, "extensions_page"), "versions" => new Paginator($versions, 25, "versions_page"), "notes" => new Paginator($notes, 25, "notes_page"), "search" => $_GET['query']), fix(_f("Search results for \"%s\"", $_GET['query'])));
}
示例10: tagNote
public function tagNote($notebookId, $noteId, $toTagId)
{
Note::find($noteId)->tags()->attach($toTagId);
return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $noteId);
}
示例11: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
$extensions = array('jpg', 'gif');
$links = array();
$input = Input::all();
for ($i = 0; $i < count(Input::get('link')); $i++) {
array_push($links, $input['link'][$i]);
}
if (!empty($_POST['delete'])) {
// Loop to store and display values of individual checked checkbox.
foreach ($_POST['delete'] as $selected) {
Image::whereId($selected)->delete();
}
}
if (isset($input['image'])) {
if (getimagesize($input['image']) != 0) {
$ext = Input::file('image')->getClientOriginalExtension();
if (in_array($ext, $extensions)) {
$image = file_get_contents($input['image']);
Image::create(['image_name' => Input::file('image')->getClientOriginalName(), 'user' => Input::get('user'), 'image' => $image, 'ext' => $ext]);
} else {
return View::make('sessions.try_again');
}
} else {
return View::make('sessions.try_again');
}
}
$note = Note::find($id);
$note->note = Input::get('note');
$note->tbd = Input::get('tbd');
$note->link = serialize($links);
$note->save();
return Redirect::route('home.index');
}
示例12: edit
/**
* Show the form for editing the specified note.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$note = Note::find($id);
return View::make('notes.edit', compact('note'));
}
示例13: required_params
<?php
required_params('note');
if (!empty(Request::$params->note['post_id'])) {
$note = Note::blank(array('post_id' => Request::$params->note['post_id']));
} elseif (!empty(Request::$params->id)) {
$note = Note::find(Request::$params->id);
}
if (!$note) {
exit_with_status(400);
}
if ($note->is_locked()) {
respond_to_error("Post is locked", array('post#show', 'id' => $note->post_id), array('status' => 422));
}
// $note->attributes = Request::$params->note;
$note->add_attributes(Request::$params->note);
$note->user_id = User::$current->id;
$note->ip_addr = Request::$remote_ip;
if ($note->save()) {
respond_to_success("Note updated", '#index', array('api' => array('new_id' => $note->id, 'old_id' => (int) Request::$params->id, 'formatted_body' => $note->formatted_body())));
} else {
respond_to_error($note, array('post#show', 'id' => $note->post_id));
}