gongpex Posted April 26, 2016 Share Posted April 26, 2016 Hello everyone, Yesterday I tried to using laravel PHP framework besides CI (code igniter), and actually this more complicated than code igniter, I tried to retrieve data from database using users.blade.php file like this : <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Laravel PHP Framework</title> <style> @import url(//fonts.googleapis.com/css?family=Lato:700); body { margin:0; font-family:'Lato', sans-serif; text-align:center; color: #999; } .welcome { width: 300px; height: 200px; position: absolute; left: 50%; top: 50%; ; margin-top: -100px; } a, a:visited { text-decoration:none; } h1 { font-size: 32px; margin: 16px 0 0 0; } </style> </head> <body> @extends('layout') @section('content') @foreach($users as $user) <p>{{ $user->name }}</p> @endforeach @stop </body> </html> and this my another file : layout.blade.php <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Laravel PHP Framework</title> <style> @import url(//fonts.googleapis.com/css?family=Lato:700); body { margin:0; font-family:'Lato', sans-serif; text-align:center; color: #999; } .welcome { width: 300px; height: 200px; position: absolute; left: 50%; top: 50%; ; margin-top: -100px; } a, a:visited { text-decoration:none; } h1 { font-size: 32px; margin: 16px 0 0 0; } </style> </head> <body> <h1>Laravel quick start</h1> @yield('content') </body> </html> this my routes : <?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::get('users', function() { $users = User::all(); return View::make('users')->with('users',$users); }); and this my model (User.php) : <?php use Illuminate\Auth\UserTrait; use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableTrait; use Illuminate\Auth\Reminders\RemindableInterface; class User extends Eloquent implements UserInterface, RemindableInterface { use UserTrait, RemindableTrait; /** * The database table used by the model. * * @var string */ protected $table = 'users'; /** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = array('password', 'remember_token'); } I'm still try using laravel quickstart documentation but the result like this : Whoops, looks like something went wrong.Q : what's wrong with my code?? please help me Thanks Link to comment Share on other sites More sharing options...
dsonesuk Posted April 26, 2016 Share Posted April 26, 2016 Should it not be @extends('layouts.layout'), I admit its a long time since I used Laravel and that was version 4 and its change a lot since then. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now