本文整理汇总了PHP中Element::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::find方法的具体用法?PHP Element::find怎么用?PHP Element::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$element = Element::find($id);
$element->elementLabel = $request->elementLabel;
$element->elementColor = $request->elementColor;
$element->elementImage = $request->elementImage;
$element->save();
return \Redirect::route('element.index');
}
示例2: saveBook
public function saveBook()
{
$book = Input::get('book');
$chapters = Input::get('chapters');
$bookMdl = Book::find($book['id']);
$bookMdl->name = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $book['name']);
$bookMdl->urlname = str_replace(' ', '-', iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $book['name']));
$bookMdl->save();
foreach ($chapters as $key => $chapter) {
if ($chapter['id']) {
$chapMdl = Chapter::find($chapter['id']);
} else {
$chapMdl = new Chapter();
}
if ($chapter['id'] && $chapter['isDeleted']) {
$chapMdl->delete();
} else {
$chapMdl->book_id = $chapter['book_id'];
$chapMdl->title = $chapter['title'];
$chapMdl->markerdata = count($chapter['markerdata']) ? json_encode($chapter['markerdata']) : null;
$chapMdl->order = $chapter['order'];
$chapMdl->save();
if (count($chapter['elements'])) {
foreach ($chapter['elements'] as $key => $element) {
if ($element['id']) {
$elementMdl = Element::find($element['id']);
} else {
$elementMdl = new Element();
}
if ($element['id'] && $element['isDeleted']) {
$elementMdl->delete();
} else {
$elementMdl->chapter_id = $chapMdl->id ?: $element['chapter_id'];
$elementMdl->order = $element['order'];
$elementMdl->type = $element['type'];
if ($element['type'] == 4 || $element['type'] == 5) {
$elementMdl->content = json_encode($element['content']);
} else {
$elementMdl->content = $element['content'];
}
$elementMdl->note = $element['note'];
$elementMdl->save();
}
}
}
}
}
echo json_encode(['ok']);
}
示例3: findLink
/**
* Return a link by text or class name.
*
* @param Element $parent
* Element object to search.
* @param string $link
* Link text, CSS class, or CSS Id to look for.
*/
public function findLink($parent, $link)
{
$element = $parent->findLink($link);
if (!$element) {
$element = $parent->find('xpath', "//a[@class='{$link}']");
if (!$element) {
$element = $parent->find('xpath', "//a[@id='{$link}']");
}
}
if ($element) {
$this->initVars();
$this->vars['link-text'] = $element->getText();
}
return $element;
}