function post() { $post = Post::find(Request::route('id2')); $pageId = Request::route('id1'); $post->delete(); return Redirect::to("/admin/manage-pages/{$pageId}/content"); }
function currentPost() { $postId = Request::route('id2'); if (isset($postId)) { return Post::find($postId); } else { return null; } }
function definition($def = []) { $is = []; $sectionId = Post::find(Request::route('id2'))->section()->first()->id; foreach (Item::where('section_id', '=', $sectionId)->get() as $item) { $content = $item->content()->where('post_id', '=', Request::route('id2'))->get()->first(); $is = $item->render($is, $content); } return parent::definition(['Form ID' => $this->getHeader() . "-form", 'Submit Button Text' => 'Save', 'Inputs' => $is]); }
function post() { foreach (json_decode(Input::get('json')) as $i) { $c = Post::find($i->id); $c->sort = $i->sort; $c->save(); } Session::flash('Success Message', 'Saved sort order'); return \Redirect::to("/admin/manage-pages/" . Request::route('id1') . "/content"); }
function def($postId) { $this->firstRow(); $this->addCell('#'); $this->addCell('Name'); $this->addCell('Actions'); $this->nextRow(); $pageId = Request::route('id1'); $post = Post::find($postId); foreach ($post->attachments()->get() as $att) { $this->addCell('1. '); $this->addCell($att->name); $this->addCellViews([(new ButtonItem())->cssClass("btn-default btn-sm")->target('_blank')->label('Download')->defaultValue("/admin/manage-pages/" . $pageId . "/posts/" . $post->id . "/attachments/{$att->id}/download"), (new ButtonItem())->cssClass("btn-default btn-sm")->label('Edit')->defaultValue("/admin/manage-pages/" . $pageId . "/posts/" . $post->id . "/attachments/{$att->id}/edit"), (new ButtonItem())->cssClass("btn-default btn-sm")->label('Delete')->defaultValue("/admin/manage-pages/" . $pageId . "/posts/" . $post->id . "/attachments/{$att->id}/delete")]); // $this->addCellView(); $this->nextRow(); } return parent::definition(); }
function __construct() { parent::controllerClass('PageSummaryAttachments'); parent::headerPlural('Page Attachments'); parent::headerSingular('Page Attachment'); parent::baseRoute('/admin/manage-pages/{id1}/posts/{id2}/attachments'); parent::ajaxBaseRoute('/ajax/admin/manage-pages/{id1}/posts/{id2}/attachments'); parent::table(new Attachment()); $this->level = 3; parent::attributes([['title' => 'ID', 'id' => 'id'], ['title' => 'Post', 'id' => 'post.name'], ['title' => 'Name', 'id' => 'name'], ['title' => 'Type', 'id' => 'item_type.name']]); parent::inputs(function ($row) { $pageId = Request::route("id1"); $page = Page::find($pageId); $postId = Request::route("id2"); $post = Post::find($postId); return ['name' => (new TextBox())->id('name')->label('Name')->defaultValue($row ? $row->name : ''), 'post_id' => (new MetaItem())->id('post_id')->defaultValue($post->id), 'file' => (new ElfinderFileInput())->id('value')->valueField('value')->label('File')->defaultValue($row ? $row->value : ''), 'item_type_id' => (new DropDown())->id('item_type_id')->nullable(false)->label('Type')->idField('id')->nameField('name')->rows(ItemType::whereIn('short_name', ["image", "file"])->get())->defaultValue($row ? $row->item_type_id : '')]; }); $this->parentHeader = 'Edit Page'; parent::tableName('attachment'); }
function post() { $post = Post::find(Request::route('id2')); $pageId = Request::route('id1'); $sectionId = $post->section()->first()->id; $inputs = $this->inputs(Post::find(Request::route('id2'))); foreach ($inputs as $input) { $item = Item::find($input->id); $content = $item->content()->where('post_id', '=', $post->id)->get()->first(); if (isset($content) === false) { $content = new Content(); $content->item_id = $item->id; $content->post_id = $post->id; $input->insert($content, Input::get("{$item->id}")); } else { $input->update($content, Input::get("{$item->id}")); } $content->save(); } return Redirect::to("/admin/manage-pages/{$pageId}/content"); }