PT-83
7 months ago
969
6
Laravel

(Laracast) Render Dynamic Data 2 - Stuck!

Posted 7 months ago by PT-83

During the Laracasts video, I'm following along setting up the articles webpage.

I'm stuck, for some reason, the articles webpage (which I called $blog) doesn't load a new screen or I get a 404 if I change the name in the layout file. Trying to figure this out for some time, I'm sure its something small I've missed but I honestly can't figure it out. I posted most of the code below hopefully... Any idea?


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900" rel="stylesheet" />
<link href="/css/default.css" rel="stylesheet" />
<link href="/css/fonts.css" rel="stylesheet" />

</head>
<body>
<div id="header-wrapper">
    <div id="header" class="container">
        <div id="logo">
            <h1><a href="/">SimpleWork</a></h1>
        </div>
        <div id="menu">
            <ul>
                <li class="{{ Request::path() === '/' ? 'current_page_item' : '' }}"><a href="/" accesskey="1" title="">Homepage</a></li>
                <li class="{{ Request::path() === 'portfolio' ? 'current_page_item' : '' }}"><a href="#" accesskey="2" title="">Portfolio</a></li>
                <li class="{{ Request::path() === 'about' ? 'current_page_item' : '' }}"><a href="/about" accesskey="3" title="">About Us</a></li>
                <li class="{{ Request::path() === 'blogs' ? 'current_page_item' : '' }}"><a href="/show" accesskey="4" title="">Blog</a></li>
                <li class="{{ Request::path() === 'contact' ? 'current_page_item' : '' }}"><a href="#" accesskey="5" title="">Contact</a></li>
            </ul>
        </div>
    </div>

    @yield ('header')

</div>
@yield ('content')

<div id="copyright" class="container">
    <p>&copy; Untitled. All rights reserved. | Photos by <a href="http://fotogrph.com/">Fotogrph</a> | Design by <a href="http://templated.co" rel="nofollow">TEMPLATED</a>.</p>
</div>

</body>
</html>



WEB PHP

Route::get('/', function () {
    return view('welcome');
});

Route::get('/about', function () {
    $blogs = App\Blog::take(3)->latest()->get();

    return view('/about', [
        'blogs' => $blogs
    ]);
});

Route::get('/blogs/{blog}', '[email protected]');



BlogController

<?php

namespace App\Http\Controllers;

use App\blog;
use Illuminate\Http\Request;

class BlogsController extends Controller
{
    public function show($id)
    {

        $blog = Blog::find($id);

        return view('blogs.show', ['blog'=> $blog]);
    }
}



SHOW.BLADE

@extends ('layout')

@section ('content')

<div id="wrapper">
    <div id="page" class="container">
        <div id="content">
            <div class="title">
                <h2>{{ $blog->title }} </h2>
                </div>
                
            <p><img src="/images/banner.jpg" alt="" class="image image-full" /> </p>
            <p> 
            {{ $blog->body }}
            </p>
        </div>
        </div>
        </div>
@endsection

Please sign in or create an account to participate in this conversation.