本文整理汇总了PHP中Page::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::find方法的具体用法?PHP Page::find怎么用?PHP Page::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: togglePublish
/**
* @param $id
*
* @return mixed
*/
public function togglePublish($id)
{
$page = $this->page->find($id);
$page->is_published = $page->is_published ? false : true;
$page->save();
return Response::json(array('result' => 'success', 'changed' => $page->is_published ? 1 : 0));
}
示例2: action_update
public function action_update($id)
{
$post_page = Input::get('postpage') ? 1 : 0;
$page = Page::where('page_name', '=', str_replace('-', '', Input::get('sub')))->first();
$order = Page::order_by('created_at', 'desc')->first();
$level = Input::get('subpage') ? $page->level + 1 : 0;
$parent = Input::get('subpage') ? $page->slug : 'none';
$slug = $this->slugger(Input::get('title'));
$oldpage = Page::find($id);
$oldpage->page_name = Input::get('title');
$oldpage->page_content = Input::get('content');
$oldpage->level = $level;
$oldpage->parent = $parent;
$oldpage->post_page = $post_page;
$success = $oldpage->save();
if (Input::get('subpage')) {
$p = Page::where('page_name', '=', str_replace('-', '', Input::get('sub')))->first();
$p->has_child = '1';
$p->save();
}
if (!$success) {
Log::write('/admin/pages/:id/edit', 'could not update page - $oldpage->save returned false');
return Redirect::to("admin/pages/{$oldpage->id}/edit")->with('error_update', 'page could not be updated');
}
return Redirect::to("admin/pages/{$oldpage->id}/edit")->with('status_update', 'page updated');
}
示例3: createComponentPageEditForm
protected function createComponentPageEditForm($name)
{
$form = $this->createPageFormBase($name, false);
if (!$form->isSubmitted()) {
$id = $this->getParam("id");
$page = Page::find($id);
$values = $page->getValues();
$values["tags"] = $page->Tags->fetchColumn("id");
$form->setDefaults($values);
}
$presenter = $this;
$form->onSubmit[] = function ($form) use($presenter) {
$values = $form->values;
try {
$page = Page::create($values);
$page->Tags = array_map(function ($id) {
return Tag::create($id);
}, $values["tags"]);
$page->save();
$presenter->flashMessage("Page '{$page->name}' was changed!");
$presenter->redirect("default", array("id" => $page->id));
} catch (ModelException $e) {
$page->addErrorsToForm($form);
}
};
}
示例4: destroy
public function destroy($id)
{
$page = Page::find($id);
//$page->delete();
Notification::success('The page was deleted.');
return Redirect::route('admin.pages.index');
}
示例5: index
public function index()
{
$page = Page::find(1);
$menuItems = Page::where('parent_id', 0)->get();
$news = News::with('user')->orderBy('created_at', 'desc')->first();
return View::make('front.pages.index')->with(['page' => $page, 'news' => $news, 'menuitems' => $menuItems]);
}
示例6: test_delete
public function test_delete()
{
$pageService = new PageService(666);
$page = $pageService->save(true, ['en_US' => new PageLangDTO('Name US', 'Content US', 'SEO Title US', 'SEO Description US', 'handle-us')]);
$this->DELETE("/666/pages/{$page->id}");
$page = Page::find($page->id);
$this->assertNotNull($page->deleted_at);
}
示例7: view
function view()
{
if (isset($_REQUEST['id'])) {
$page = new Page();
$this->columns = $page->_columns;
$this->page = $page->find($_REQUEST['id']);
}
}
示例8: findOnPage
/**
* Retrieves the given $url and returns the first match for the nonce regex or false if not found.
*
* @param \Requests_Session $session The session to send the request from.
* @param string $url The page URL.
* @param string $regex The regex to use to find the nonce. It must have a single capture group.
*
* @return string|false The nonce if found, otherwise false.
*/
public static function findOnPage(\Requests_Session $session, $url, $regex = '/name="_wpnonce"\\s+value="(.+?)"/')
{
//TODO: improve this to be more than just a dumb regex match
$nonceMatches = Page::find($session, $url, $regex);
if (!is_array($nonceMatches) || count($nonceMatches) < 2 || empty($nonceMatches[1])) {
return false;
}
return $nonceMatches[1];
}
示例9: listPagesUrl
public static function listPagesUrl()
{
$model = Page::find()->asArray()->all();
$pages = [];
foreach ($model as $page) {
$pages[$page['url']] = $page['name'];
}
return $pages;
}
示例10: get_page
public function get_page($page_id)
{
if ($page = Page::find($page_id)) {
if (Auth::check()) {
History::add_page($page_id);
}
return view('content.page')->with('page', $page);
}
return Response::error('404');
}
示例11: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($url_seo)
{
$page = DB::table('banners')->where('url_seo', '=', $url_seo)->first();
$id = $page->id;
$page = Page::find($id);
$page->visitas++;
$page->save();
// show the view and pass the nerd to it
return View::make('pages.show', array('page' => $page));
}
示例12: showDetails
public function showDetails($id)
{
$page = Page::find($id);
// If no item in database
if (empty($page) || empty($page->id)) {
return Redirect::route('home')->with('message', Lang::get('pages.inexistant'));
}
$this->layout->content = View::make('public.pages.details');
$this->layout->content->page = $page;
$this->layout->content_title = $page->title;
}
示例13: find
/**
* Scoped finder for page versions
*
* @param page page object or page_id as number
* @return array of page objects or null
*/
public static function find($args = null)
{
if (is_array($args)) {
if (array_key_exists('where', $args) and !empty($args['where'])) {
$args['where'] .= ' and (behavior_id="version" or behavior_id="current_version")';
} else {
$args['where'] = '(behavior_id="version" or behavior_id="current_version")';
}
}
return parent::find($args);
}
示例14: getPageList
/**
* ページリストを取得する
*
* @param string $categoryId
* @return mixed boolean / array
* @access public
*/
function getPageList($categoryId = null)
{
if ($this->Page) {
$conditions = array('Page.status' => 1);
if ($categoryId) {
$conditions['Page.page_category_id'] = $categoryId;
}
$this->Page->unbindModel(array('belongsTo' => array('PageCategory')));
$pages = $this->Page->find('all', array('conditions' => $conditions, 'fields' => array('title', 'url'), 'order' => 'Page.sort'));
return Set::extract('/Page/.', $pages);
} else {
return false;
}
}
示例15: minus
/**
* @param $postId
* @param \User $author
* @return bool|void
*/
public static function minus($postId, \User $author)
{
$page = \Page::find(intval($postId));
if (!$page) {
return false;
}
if ($page->author_id == $author->id) {
return $page->author_id;
}
if ($page->author->rate(-1)) {
return $page->author_id;
}
return false;
}