Now I admit I am slightly new to laravel still, but to me this just does not make sense. The model that goes along with this table contains only 2 functions, both containing a relationship statement.
I am using Laravel4, mysql, php 5.5
Any ideas are welcome :D
The database record-definitions are for both DATETIME, allow null and no default value (changed that after the screenshots)
the $challenge variable is part of the data I pass on to the view like so:
$challenges = Auth::user()->challenges;
$data['challenges'] = $challenges;
return View::make("challenges/topic", $data);
and in the view I use
@foreach($challenges as $challenge)
read the challenge values (I am aware I cant echo like that without php tags or {{ }}, just easier to explain)
echo gettype($challenge->deadline) // results in string
echo gettype($challenge->created_at) // results in object
Depends on how you access it, if you do:
Route::any('test', ['as' => 'test', function()
{
$a = Article::first();
var_dump( gettype($a->created_at) );
$a = DB::table('articles')->first();
var_dump( gettype($a->created_at) );
}]);
You will get:
string 'object' (length=6) /// This is Eloquent
string 'string' (length=6) /// This is the QueryBuilder directly accessing your table
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.