Feature/eloquent unix timestamps #769

Closed
wants to merge 4 commits into
from

Projects

None yet
@JesseObrien

In regards to #705

Andrew Ellis and others added some commits May 23, 2012
Andrew Ellis implemented the ability to use unix timestamps on models 462f9aa
@JesseObrien JesseObrien Merge branch 'master' of https://github.com/laravel/laravel into feat…
…ure/eloquent-unix-timestamps
838e9cc
@JesseObrien JesseObrien Added unix_timestamps() method to schema builder.
On recommendation from @taylorotwell, unix_timestamps adds a way to
specify a timestamp field should be created as a unix_timestamp field
instead of a date-time field.
a9198b3
@JesseObrien JesseObrien Update Schema docs to reflect unix_timestamps() method. 856b793
@afarazit
afarazit commented Jul 4, 2012

+1

@Apathetic012

👍

@koltroll

+1

@guilambert

+1

@ellisio
ellisio commented Aug 10, 2012

Is this ever going to get pulled in? Starting to get annoying having to recreate all these files for new projects :(

@ellisio
ellisio commented Aug 10, 2012

Looks like a timestamp() function was added to Eloquent. Did not notice that. Nice!

@daylerees
Member

Hi @awellis13 I will nag @taylorotwell about this one. It seems greatly desired and Eloquent is his baby.

Thanks man!

@JesseObrien

Yeah I've had to hack together a base model to use in all of our projects now, it would be nice to have this pulled. @awellis13 did a nice job on it.

@franzliedke

Taylor doesn't like non-expressive parameters like the one you added to the date() function, though.

I'd suggest you actually leave that in, but also add another function, maybe unix_date(), that only accepts one parameter and then calls date() with that parameter (or maybe doesn't rely on it, it's simple enough to re-implement).

@crynobone

Since $column is an instance of Laravel\Fluent, would it be better to use it as

Schema::create('users', function ($table)
{
    $table->date('created_at')->unix();
});
@crynobone crynobone commented on the diff Aug 11, 2012
laravel/database/eloquent/model.php
@@ -185,12 +185,36 @@ public function fill_raw(array $attributes)
*/
public static function accessible($attributes = null)
{
- if (is_null($attributes)) return static::$accessible;
+ if (is_null($attributes)) {
@crynobone
crynobone Aug 11, 2012

most Laravel code use own line for braces*, and condition without semicolon is accepted by in Laravel (since @taylorotwell use it mostly)

  • edited
@franzliedke
franzliedke Aug 11, 2012

Semicolon? Braces. (Just trying to avoid confusion :) ).

@franzliedke

@crynobone Good idea. That would set the field unix to true on the Fluent object, right?

@crynobone

should work the same as nullable, on mobile right now, it either true or isset

@taylorotwell
Member

This has been addressed in Eloquent 3 / Laravel 4.

@mhayes14

Does anybody know how has this been addressed in Laravel 4? I can't find any reference to unix timestamps in the documentation or source. I don't really want to have to 1) define two integers on every new table, where timestamps() was sufficient before and 2) set freshTimestamp() on every model. Is there no implementation similar to this pull request available?

@nathggns

In the same boat as @BlueHayes. How was this fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment