예제 #1
0
파일: Post.php 프로젝트: wislem/berrier
 public static function boot()
 {
     parent::boot();
     Post::deleting(function ($post) {
         // Delete all media associated with this item (iterated for media boot too)
         foreach ($post->media as $medium) {
             $medium->delete();
         }
     });
 }
예제 #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $widget = $this->widget->findOrFail($id);
     $pages = Page::join('page_translations as t', 't.page_id', '=', 'pages.id')->lists('title', 'id')->toArray();
     $posts = Post::join('post_translations as t', 't.post_id', '=', 'posts.id')->lists('title', 'id')->toArray();
     $categories_tree = Category::withDepth()->defaultOrder()->descendantsOf(1)->linkNodes();
     $categories = renderTreeToOptions($categories_tree);
     return view('berrier::admin.widgets.edit')->with(compact('pages'))->with(compact('categories'))->with(compact('posts'))->with(compact('widget'));
 }