Пример #1
0
 /**
  * @return mixed
  */
 public function index()
 {
     $notas = Post::all();
     $imgem = asset('img/paris1.jpg');
     $view = view('blog/index')->with('imagem', $imgem)->with(compact('notas'));
     return $view;
 }
Пример #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     factory('Blog\\Post', 10)->create();
     $lastTag = count(Tag::all()) - 1;
     $posts = Post::all();
     foreach ($posts as $post) {
         # code...
         $rand = rand(0, 5);
         for ($i = 1; $i < $rand; $i++) {
             # code...
             $tag = Tag::find(rand(0, $lastTag));
             $post->tags()->attach($tag);
         }
     }
 }
Пример #3
0
 public function post($id)
 {
     $post = Blog\Post::find($id);
     $posts = Blog\Post::all(['id', 'title']);
     return view('posts.post', compact(['post', 'posts']));
 }