我正在制作我的第一个 Larevel (4) 应用程序,我想显示它的创建日期,我遇到了这个问题:Unexpected data found. Unexpected data found. Unexpected data found. Data missing
当我尝试在刀片模板中执行此操作时
@extends('layout')
@section('content')
<h3>Name: {{ $user->name }}</h3>
<p>Email: {{ $user->email }}</p>
<p>Bio: {{ $user->bio }}</p>
@endsection()
@section('sidebar')
<p><small>{{ $user->created_at }}</small></p>
@endsection()
@stop
和我的控制器
<?php
class UserController extends BaseController
{
public $restfull = true;
public function get_index() {
//$users = User::all();// gets them in the order of the database
$users = User::orderBy("name")->get(); // gets alphabetic by name
$v = View::make('users');
$v->users = $users;
$v->title = "list of users";
return $v;
}
public function get_view($id) {
$user = User::find($id);
$v = View::make('user');
$v->user = $user;
$v->title = "Viewing " . $user->name;
return $v;
}
}
?>
我一拿出来它就起作用了:
<p><small>{{ $user->created_at }}</small></p>"
我检查了如何访问这些值的任何想法,它们确实存在于我的表中。
这是我的表的架构
CREATE TABLE "users" ("id" integer null primary key autoincrement, "email" varchar null, "name" varchar null, "bio" varchar null, "created_at" datetime null, "updated_at" datetime null);