function post()
 {
     $pageId = Request::route('id1');
     $sectionId = Request::route('id2');
     $section = Section::find($sectionId);
     $inputs = $this->inputs();
     $post = new Post();
     $post->page_id = $pageId;
     $post->section_id = $sectionId;
     $post->name = $section->name;
     $post->description = $section->description;
     $post->save();
     foreach ($inputs as $input) {
         $item = Item::find($input->id);
         $content = null;
         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");
 }
Example #2
0
 function __construct()
 {
     parent::controllerClass('Feeds');
     parent::headerPlural('Feeds');
     parent::headerSingular('Feed');
     parent::baseRoute('/admin/feeds');
     parent::ajaxBaseRoute('/ajax/admin/feeds');
     parent::table(new Feed());
     parent::attributes([['title' => 'ID', 'id' => 'id'], ['title' => 'Name', 'id' => 'name'], ['title' => 'URL', 'id' => 'url'], ['title' => 'Page', 'id' => 'page.name'], ['title' => 'Section', 'id' => 'section.name']]);
     parent::inputs(function ($row) {
         return ['name' => (new TextBox())->id('name')->label('Name')->defaultValue($row ? $row->name : ''), 'url' => (new TextBox())->id('url')->label('URL')->defaultValue($row ? $row->url : ''), 'page_id' => (new DropDown())->id('page_id')->nullable(false)->label('Page')->idField('id')->nameField('name')->rows(Page::get())->defaultValue($row ? $row->page_id : ''), 'section_id' => (new DropDown())->id('section_id')->nullable(false)->label('Section')->idField('id')->nameField('name')->rows(Section::get())->defaultValue($row ? $row->section_id : '')];
     });
     parent::tableName('feed');
 }
Example #3
0
 function dataAll()
 {
     return $this->table->where('page_id', '=', Request::route('id1'))->whereIn('section_id', Section::where('single', '=', 0)->lists('id'))->with('section')->get();
 }
Example #4
0
 function countPosts($name)
 {
     return Post::where('page_id', '=', $this->id)->whereIn('section_id', Section::where('name', '=', $name)->lists('id'))->count();
 }