zelaza

zelaza

Member Since 1 Year Ago

Experience Points 1,130
Experience
Level
Lessons Completed 1
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

03 Dec
1 year ago

zelaza left a reply on Clearing A Beanstalkd Queue On Forge

I have the same question. Any answers?

30 Jul
1 year ago

zelaza left a reply on Best Practice For Updating Forge Servers?

Thanks, Gorby. I have the same setup - Dev and Production servers. So I think I'll follow your advice - upgrade the Dev server, test it, if all looks good then upgrade the Production server...

29 Jul
1 year ago

zelaza started a new conversation Best Practice For Updating Forge Servers?

Hi. I have several Laravel apps running on Forge servers. I'm a coder, not a sys admin.

I understand Forge takes care of security updates for me, but not "other" package updates. When I ssh into my servers I see:

109 packages can be updated.
0 updates are security updates.

What is the best practice for updating/upgrading all those other packages? Should I / can I just upgrade them all the time? If I do so is it possible that will break my apps? What are the best apt-get commands to do the updates/upgrades?

Thanks/

zelaza left a reply on Environment Variables On Queued Jobs?

Does anyone have any thoughts on this? Seems pretty important - your config and env variables do weird, unexplainable things when accessed from inside queued jobs...?

Any help?

zelaza left a reply on Config('value') Is Not Working On Cron(laravel Scheduler)

This looks like the same problem I posted a question about recently - config and environment variables not working as expected in Laravel queued jobs.

This seems like a pretty important issue - your config and env variables do weird stuff (really weird) when accessed from inside a queued job...

Any help?

28 Jul
1 year ago

zelaza started a new conversation Incredibly Strange Env Behavior

Guys, I am struggling with something that I just cannot understand.

I have a .env file with some variables in it:

TEST=testval
FACEBOOK_APP_ID=whatever

When I access env('FACEBOOK_APP_ID') from a controller it works as expected - I get back 'whatver'.

env('TEST') works as expected, both in the controller and in the queued job.

But when I do the same thing from a queued Job, env('FACEBOOK_APP_ID') ALWAYS returns the value 469738190039286 - even when I delete the FACEBOOK_APP_ID line from the .env file.

It's as if something is "overwriting" env('FACEBOOK_APP_ID')...

I'm not kidding - this is really happening.

Any ideas?

Thanks.

16 May
1 year ago

zelaza started a new conversation Queued Broadcast Events Not Working

Hi. I'm trying to get Broadcast Events working in Laravel 5.4. I've been killing myself for days trying to get them to work, and in a final act of desperation I changed:

class TestEvent implements ShouldBroadcast

to

class TestEvent implements ShouldBroadcastNow

in my TestEvent class, effectively bypassing the queue, and all of a sudden it works.

My queues are working fine - I use them for other things that are working.

Does anyone know why this would work without queuing but fail with queuing?

Thanks.

24 Apr
1 year ago

zelaza left a reply on Does Each Event Need A Listener?

Well, I tested it with Laravel 5.4 and it does indeed appear that you can fire off an Event without any corresponding entry in EventServiceProvider.php or any corresponding Listener without taking any errors. So all's right with the world.

zelaza left a reply on Does Each Event Need A Listener?

Thanks, Mike - I will give that a try - it's better than having to create "dummy" Listener classes. I'm also going to re-test what happens if I fire an Event that has no corresponding key in the $listen array at all.

In general I think we should be able to fire off an Event without any requirement to define a Listener, even an empty one as you are suggesting.

23 Apr
1 year ago

zelaza started a new conversation Does Each Event Need A Listener?

Hi. I'm building a Laravel package, and I want it do dispatch Events that may or may not have Listeners in the application. I seem to recall that if I dispatch an Event that doesn't have a Listener, I get an error? Is that still true and, if so, why, and is there a way to get around it other than creating "placeholder" do-nothing Listeners just to avoid taking the error?

It seems like we should be able to dispatch Events that don't necessarily have Listeners, no?

22 Apr
1 year ago

zelaza left a reply on [L5] Register A Route Middleware At Package

This is such a beautiful thing. But to make it work in 5.4 do the following:

public function boot(\Illuminate\Routing\Router $router) {
    $router->aliasMiddleware('name', 'MiddlewareClass');
}
14 Mar
1 year ago

zelaza left a reply on Laravel 5.4 Mix: How To Version Some Files But Not Others?

Wish someone would answer this...

07 Mar
1 year ago

zelaza left a reply on Can't Get Later() To Delay Queued Emails (in Laravel 5.4)

Thanks, KenoKokoro.

After further investigation it turns out that I had my QUEUE_DRIVER environment variable set to 'sync' rather than 'beanstalkd'.

Changing it to 'beanstalkd' solved the problem.

06 Mar
1 year ago

zelaza started a new conversation Can't Get Later() To Delay Queued Emails (in Laravel 5.4)

I can't seem to get the later() function to actually delay the sending of emails. When I do this:

$when = Carbon::now()->addMinutes(5);
$mailJob = (new WelcomeEmail($emailData))->onQueue('mail');
Mail::to($emailAddress)->later($when, $mailJob);

or this:

$mailJob = (new WelcomeEmail($emailData))->onQueue('mail');
Mail::to($emailAddress)->later(300, $mailJob);

the emails go out immediately - I'm not even sure they're being queued at all let alone delayed... Any thoughts? Thanks.

27 Feb
1 year ago

zelaza started a new conversation Global Scopes Break Static Methods In Eloquent Models...?

I have a public static method defined in an Eloquent Model, something like:

class MyBlurf extends Model {

    public static function blurf() {
        return 'blurf';
    }

}

When I have no Global Scopes defined on the Model the following works fine:

$strBlurf = MyBlurf::blurf();

But when I add a Global Scope to the Model:

class MyBlurf extends Model {

    protected static function boot()
    {
        parent::boot();
        static::addGlobalScope(new UserScope);
    }

    public static function blurf() {
        return 'blurf';
    }

}

and I do:

$strBlurf = MyBlurf::blurf();

I get:

BadMethodCallException: Call to undefined method Illuminate\Database\Query\Builder::blurf() in /home/forge/xxx/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2508

How can I make Global Scopes and Static Methods work at the same time??

26 Feb
1 year ago

zelaza started a new conversation Constructors And The Artisan Route:list Command

The Artisan route:list command seems to need to instantiate all of your Controllers, so if you ever put anything in a Controller constructor that causes an error when the constructor gets called from the command line, you will break your php artisan route:list command, which is not a happy thing.

You can usually prevent this by carefully avoiding putting anything in any of your Controller constructors that would cause an error when run from the artisan command line.

However, there are certain situations where it makes really good programming sense to put something in a Controller that will take an error when called via artisan route:list (e.g. Controllers with several methods that all require a real http Request, which does not exist when the constructor is called by artisan).

In these cases I have been forced to put some logic in the Controller constructor that avoids taking the error by returning immediately when the constructor is being called by Artisan, e.g.:

    public function __construct(Request $request)
    {

        if ($_SERVER['PHP_SELF'] == 'artisan') {
            return null;
        }

I don't really like the above approach for a number of reasons, but it works.

Is there a "better" way to solve this problem?

19 Feb
1 year ago

zelaza started a new conversation Issue With Mix.js() On Laravel 5.4

I'm having an issue with Mix.js on Laravel 5.4. I'm trying to "compile" a simple, standalone js file that is really just anonymous, self-calling function, e.g.:

(function() {

    /* Load Script function we may need to load jQuery from the Google's CDN */
    /* That code is world-reknown. */
    /* One source: http://snipplr.com/view/18756/loadscript/ */

    var loadScript = function(url, callback){

        var script = document.createElement("script");
        script.type = "text/javascript";

    // etc, etc

I guess I don't really have to "compile" it, but I'm trying to run it through Mix.js so that it gets uglified when I run "npm run production".

But when I do "npm run dev" I get:


 ERROR  Failed to compile with 1 errors                                                                                                                                9:28:57 AM

This dependency was not found in node_modules:

* /Users/xxx/Code/test/resources/assets/yyy/js/zzz_app_a.js

Did you forget to run npm install --save for it?

Note that my source file is definitely located at "/Users/xxx/Code/test/resources/assets/yyy/js/zzz_app_a.js".

I have no idea why the error message is talking about "node_modules". I also don't know why node is calling it a "dependency"...

And I also get a Laravel Mix notice briefly flashing up on the screen that seems to say something about "Error: undefined error: can't resolve /Users..." and a path that flows out of the little message box and out of sight (is there any way to actually see the whole Laravel Mix error, by the way?).

Although it takes an error, it actually seems to "compile" the file. So I'm putting my Mix.js call for this at the very end of my webpack.mix.js file and running it with the error...

Note: this used to work fine on Elixir...

Is there a way to do what I want to do (essentially copy the js file when running "npm run dev" but uglify it when running "npm run production"), without getting errors?

zelaza left a reply on Can't Get Laravel Mix To Work - Frustration LIMIT Reached

Hi. I'm having a similar issue with Mix. I'm trying to "complile" a simple, standalone js file that is really just anonymous, self-calling functions, e.g.:

(function() {

    /* Load Script function we may need to load jQuery from the Google's CDN */
    /* That code is world-reknown. */
    /* One source: http://snipplr.com/view/18756/loadscript/ */

    var loadScript = function(url, callback){

        var script = document.createElement("script");
        script.type = "text/javascript";

        // If the browser is Internet Explorer.
        if (script.readyState){
            script.onreadystatechange = function(){
                if (script.readyState == "loaded" || script.readyState == "complete"){
                    script.onreadystatechange = null;
                    callback();
                }
            };
            // For any other browser.
        } else {
            script.onload = function(){
                callback();
            };
        }

        script.src = url;
        document.getElementsByTagName("head")[0].appendChild(script);

etc, etc

I guess I don't really have to "compile" it, but I'm trying to run it through Mix.js so that it gets uglified when I run "npm run production".

But when I do "npm run dev" I get:


 ERROR  Failed to compile with 1 errors                                                                                                                                9:28:57 AM

This dependency was not found in node_modules:

* /Users/xxx/Code/test/resources/assets/yyy/js/zzz_app_a.js

Did you forget to run npm install --save for it?

Although it takes an error, it actually seems to "compile" the file. So I'm putting my Mix.js call for this at the very end of my webpack.mix.js file and running it with the error...

Is there a way to do what I want to do (without getting errors)?

10 Feb
1 year ago

zelaza started a new conversation How To Use Spark Without Billing Plans?

Hi. What is the best way to use Spark with no billing, or with only a Free Plan and defaulting to the Free Plan? Thanks.

zelaza left a reply on How To Register/Create A User Programmatically?

Thanks very much, themsaid. That looks like what I need. I will try it!

08 Feb
1 year ago

zelaza left a reply on How To Register A User Programmatically?

Thanks for the response, Ben. I actually started thinking about something like that, but I'm thinking that since this is Spark and not just straight Laravel I can't just create a User. I think Spark does a lot more stuff when it creates a User... no?

zelaza left a reply on How To Register A User?

No ideas on how to do this...?

zelaza started a new conversation How To Register A User?

Hi. I need to register a User programmatically, without going through the normal form-based registration process.

I thought about mimicking what's in the register() method in the RegisterController:

    public function register(RegisterRequest $request)
    {
        Auth::login($user = Spark::interact(
            Register::class, [$request]
        ));

        event(new UserRegistered($user));

        return response()->json([
            'redirect' => $this->redirectPath()
        ]);
    }

but I don't know how to mimic the $request argument to Spark::interact().

So then I thought about just doing an http POST request to the [email protected]() method thus:

    public function register_user()
    {

        $data = [
            'name' => 'Joe User',
            'email' => '[email protected]',
            'password' => 'j0eybaby',
            'password_confirmation' => 'j0eybaby',
            'terms' => true,
            'busy' => true,
            'successful' => false,
            '_token' => csrf_token()
        ];

        $client = new GuzzleHttp\Client();
        $client->request('POST', 'https://www.hex1b.com/register', ['form_params' => $data]);

    }

but that gives mne a 500 Internal Server error.

Is there any way to do what I'm trying to do?

Thanks.

04 Feb
1 year ago

zelaza left a reply on Use Created_at In Accessor In Laravel 5.3?

As far as I can tell 'created_at' is not available in an Accessor.

When I do this:

    // pseudo-fields appended to models when exported to json
    protected $appends = ['age_days'];

    // return age of model in days since 'created_at'
    public function getAgeDaysAttribute() {

        Log::info("\n\n****************************************");
        Log::info('$this: ' . var_export($this, true));


        Log::info("\n\n****************************************");
        Log::info('$this->attributes: ' . var_export($this->attributes, true));

        $arrayDates = $this->getDates();
        Log::info("\n\n****************************************");
        Log::info('$arrayDates: ' . var_export($arrayDates, true));

    }

I get this:

[2017-02-04 07:43:45] production.INFO: 

****************************************  
[2017-02-04 07:43:45] production.INFO: $this: App\ShopifyInquiry::__set_state(array(
   'connection' => 'tenant',
   'fillable' => 
  array (
    0 => 'state',
  ),
   'appends' => 
  array (
    0 => 'age_days',
  ),
   'table' => NULL,
   'primaryKey' => 'id',
   'keyType' => 'int',
   'perPage' => 15,
   'incrementing' => true,
   'timestamps' => true,
   'attributes' => 
  array (
    'state' => 'Open',
    'conversions' => 0,
    'conversion_value' => '0.0000',
    'conversion_currency' => '',
    'received_at' => '2017-02-04 07:34:19',
    'received_at_date' => '2017-02-04',
  ),
   'original' => 
  array (
    'state' => 'Open',
    'conversions' => 0,
    'conversion_value' => '0.0000',
    'conversion_currency' => '',
    'received_at' => '2017-02-04 07:34:19',
    'received_at_date' => '2017-02-04',
  ),
   'relations' => 
  array (
  ),
   'hidden' => 
  array (
  ),
   'visible' => 
  array (
  ),
   'guarded' => 
  array (
    0 => '*',
  ),
   'dates' => 
  array (
  ),
   'dateFormat' => NULL,
   'casts' => 
  array (
  ),
   'touches' => 
  array (
  ),
   'observables' => 
  array (
  ),
   'with' => 
  array (
  ),
   'exists' => true,
   'wasRecentlyCreated' => false,
))  
[2017-02-04 07:43:45] production.INFO: 

****************************************  
[2017-02-04 07:43:45] production.INFO: $this->attributes: array (
  'state' => 'Open',
  'conversions' => 0,
  'conversion_value' => '0.0000',
  'conversion_currency' => '',
  'received_at' => '2017-02-04 07:34:19',
  'received_at_date' => '2017-02-04',
)  
[2017-02-04 07:43:45] production.INFO: 

****************************************  
[2017-02-04 07:43:45] production.INFO: $arrayDates: array (
  0 => 'created_at',
  1 => 'updated_at',
)  

It seems like 'created_at' is not an attribute of the model and there is no way to "get it" in an accessor...?

zelaza left a reply on Use Created_at In Accessor In Laravel 5.3?

As far as I can tell 'created_at' is not available in an accessor.

When I do this:

    // pseudo-fields appended to models when exported to json
    protected $appends = ['age_days'];
    
    // return age of model in days since 'created_at'
    public function getAgeDaysAttribute() {

        Log::info("\n\n****************************************");
        Log::info('$this: ' . var_export($this, true));


        Log::info("\n\n****************************************");
        Log::info('$this->attributes: ' . var_export($this->attributes, true));

        $arrayDates = $this->getDates();
        Log::info("\n\n****************************************");
        Log::info('$arrayDates: ' . var_export($arrayDates, true));

        // return Carbon::createFromFormat('Y-m-d H:i:s', $this->received_at)->diffInDays();

    }

I get this:

Last login: Fri Feb 3 21:23:16 on ttys001 Kurt-MacBook-Pro:~ laurencebertone$ ssh [email protected] Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud

107 packages can be updated. 0 updates are security updates.

*** System restart required *** Last login: Fri Feb 3 21:23:21 2017 from 96.32.44.5 [email protected]:~$ cd www* [email protected]:~/www.hex1b.com$ cd sto* [email protected]:~/www.hex1b.com/storage$ cd logs [email protected]:~/www.hex1b.com/storage/logs$ rm *.log [email protected]:~/www.hex1b.com/storage/logs$ ls laravel.log [email protected]:~/www.hex1b.com/storage/logs$ vi *.log [email protected]:~/www.hex1b.com/storage/logs$ vi *.log [email protected]:~/www.hex1b.com/storage/logs$ rm *.log [email protected]:~/www.hex1b.com/storage/logs$ vi *.log [email protected]:~/www.hex1b.com/storage/logs$ rm *.log [email protected]:~/www.hex1b.com/storage/logs$ vi *.log [email protected]:~/www.hex1b.com/storage/logs$ rm .log [email protected]:~/www.hex1b.com/storage/logs$ cd [email protected]:~$ cd www [email protected]:~/www.hex1b.com$ php artisan tenant_migrate:reset

  • Application In Production!     *
    

Do you wish to continue? [y|n] (yes/no) [no]:

yes

Tenant Database: db_1 Rolled back: 2016_12_31_150500_create_shopify_inquirers_table Rolled back: 2016_12_29_230500_create_shopify_customers_table Rolled back: 2016_11_28_235855_create_shopify_inquiries_table [email protected]:~/www.hex1b.com$ php artisan tenant_migrate:migrate

  • Application In Production!     *
    

Do you wish to continue? [y|n] (yes/no) [no]:

yes

Tenant Database: db_1

[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'received_at' (SQL: create table shopify_inquiries (id int unsigned not null auto_incre ment primary key, type varchar(255) not null, shop varchar(255) not null, shop_name varchar(255) not null, first_name varchar(255) not null, last_name varchar(255) not null, name varchar(255) not null, email varchar(255) not null, product_id varchar(255) not null, product_title varchar(255) not null, product_image_url varcha r(255) not null default '', product json not null, variant_id varchar(255) not null, sku varchar(255) not null, variant_title varchar(255) not null, variant_url va rchar(255) not null, variant json not null, window_location json not null, theme json not null, path_prefix varchar(255) not null, timestamp varchar(255) not null, signature varchar(255) not null, comment text null, state enum('Archived', 'Closed', 'Converted', 'Deferred', 'Fulfilled', 'Open') not null default 'Open', state_bef ore_archived enum('Closed', 'Converted', 'Deferred', 'Fulfilled', 'Open') null, was_closed tinyint(1) not null default '0', was_closed_at timestamp null, was_fulfilled tinyint(1) not null default '0', was_fulfilled_at timestamp null, was_deferred tinyint(1) not null default '0', was_deferred_at timestamp null, was_converted tinyi nt(1) not null default '0', was_converted_at timestamp null, was_archived tinyint(1) not null default '0', was_archived_at timestamp null, conversions int not null d efault '0', conversion_currency varchar(255) not null default '', conversion_value decimal(13, 4) not null default '0', customer_value decimal(13, 4) not null default '0', received_at_date date not null, received_at timestamp not null, last_checked_at timestamp null, resolved_at timestamp null, created_at timestamp null, update d_at timestamp null) default character set utf8 collate utf8_unicode_ci)

[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'received_at'

[email protected]:~/www.hex1b.com$ [email protected]:~/www.hex1b.com$ [email protected]:~/www.hex1b.com$ php artisan tenant_migrate:migrate

  • Application In Production!     *
    

Do you wish to continue? [y|n] (yes/no) [no]:

yes

Tenant Database: db_1 Migrated: 2016_11_28_235855_create_shopify_inquiries_table Migrated: 2016_12_29_230500_create_shopify_customers_table Migrated: 2016_12_31_150500_create_shopify_inquirers_table [email protected]:~/www.hex1b.com$ [email protected]:~/www.hex1b.com$ cd sto* [email protected]:~/www.hex1b.com/storage$ cd logs [email protected]:~/www.hex1b.com/storage/logs$ vi *.log [email protected]:~/www.hex1b.com/storage/logs$ [email protected]:~/www.hex1b.com/storage/logs$ [email protected]:~/www.hex1b.com/storage/logs$ rm *.log [email protected]:~/www.hex1b.com/storage/logs$ ls -la total 12 drwxrwxr-x 2 forge forge 4096 Feb 4 07:33 . drwxrwxr-x 5 forge forge 4096 Jan 5 23:02 .. -rw-rw-r-- 1 forge forge 14 Dec 8 21:16 .gitignore [email protected]:~/www.hex1b.com/storage/logs$ ls -la total 12 drwxrwxr-x 2 forge forge 4096 Feb 4 07:33 . drwxrwxr-x 5 forge forge 4096 Jan 5 23:02 .. -rw-rw-r-- 1 forge forge 14 Dec 8 21:16 .gitignore [email protected]:~/www.hex1b.com/storage/logs$ ls -la total 16 drwxrwxr-x 2 forge forge 4096 Feb 4 07:33 . drwxrwxr-x 5 forge forge 4096 Jan 5 23:02 .. -rw-rw-r-- 1 forge forge 14 Dec 8 21:16 .gitignore -rw-r--r-- 1 forge forge 2871 Feb 4 07:34 laravel.log [email protected]:~/www.hex1b.com/storage/logs$ vi *.log [email protected]:~/www.hex1b.com/storage/logs$ rm *.log [email protected]:~/www.hex1b.com/storage/logs$ rm *.log [email protected]:~/www.hex1b.com/storage/logs$ vi *.log [email protected]:~/www.hex1b.com/storage/logs$ rm *.log [email protected]:~/www.hex1b.com/storage/logs$ vi *.log [email protected]:~/www.hex1b.com/storage/logs$ rm *.log [email protected]:~/www.hex1b.com/storage/logs$ vi *.log [email protected]:~/www.hex1b.com/storage/logs$ vi *.log

[2017-02-04 07:43:45] production.INFO:

[2017-02-04 07:43:45] production.INFO: $this: App\ShopifyInquiry::__set_state(array( 'connection' => 'tenant', 'fillable' => array ( 0 => 'state', ), 'appends' => array ( 0 => 'age_days', ), 'table' => NULL, 'primaryKey' => 'id', 'keyType' => 'int', 'perPage' => 15, 'incrementing' => true, 'timestamps' => true, 'attributes' => array ( 'state' => 'Open', 'conversions' => 0, 'conversion_value' => '0.0000', 'conversion_currency' => '', 'received_at' => '2017-02-04 07:34:19', 'received_at_date' => '2017-02-04', ), 'original' => array ( 'state' => 'Open', 'conversions' => 0, 'conversion_value' => '0.0000', 'conversion_currency' => '', 'received_at' => '2017-02-04 07:34:19', 'received_at_date' => '2017-02-04', ), 'relations' => array ( ), 'hidden' => array ( ), 'visible' => array ( ), 'guarded' => 1,1 Top

As shown, 'created_at' is not an attribute...

zelaza left a reply on Use Created_at In Accessor In Laravel 5.3?

By the way, I'm using Laravel Spark - I don't think that should matter, but I am...

zelaza left a reply on Use Created_at In Accessor In Laravel 5.3?

Thanks, but when I do that I get:

FatalErrorException in helpers.php line 519:

Method Illuminate\Database\Eloquent\Collection::__toString() must not throw an exception, caught ErrorException: Undefined index: created_at

03 Feb
1 year ago

zelaza left a reply on Use Created_at In Accessor In Laravel 5.3?

Thanks for responding. Yes, I tried $this->attributes['created_at'] and it failed (it was NULL). In fact even $this->attributes appeared NULL...

It's as if $this->created_at doesn't even exist, but it does (I can see it in the DB)...

zelaza started a new conversation Use Created_at In Accessor In Laravel 5.3?

Hi. I'm trying to use created_at in an model accessor method in Laravel 5.3, and I can't get it to work. Basically I am trying to create and appended property called 'age_days' using an accessor method called getAgeDaysAttribute() that returns the age of the model in days since the created_at date. But when I try to use created_at in an accessor it is always null. Here is an example of the code I have tried

   /*
     * Pseudo-fields that get added to the models when the models are exported to json.
     */
    protected $appends = ['age_days'];


    /*
     * Returns age of model in days since created_at.
     */
    public function getAgeDaysAttribute() {

        return $this->created_at->diffInDays();
        // return Carbon::createFromFormat('Y-m-d H:i:s', $this->created_at)->diffInDays();

    }
25 Jan
1 year ago

zelaza left a reply on Spark Bug

Actually, I can't even find the "Spark repo". I see laravel/spark-installer and laravel/spark-docs... How can I submit an issue? Thanks

zelaza left a reply on Spark Bug

Ok, thanks, I'll submit it as an issue. In my opinion it's a really good and important feature to have - if you are going to refuse to downgrade a user's subscription you need to tell them why RIGHT NOW - refusing to downgrade them and giving them a generic "contact support" message is a really (unacceptably) bad user experience. I did change the code myself, but I'd rather have the Spark developers make the change so that all Spark users can benefit from it.

16 Jan
1 year ago

zelaza started a new conversation Spark Bug

Hi.

I think there's a bug in the 'updateSubscription()' method of the 'subscriptions.js' mixin that's preventing messages thrown in IneligibleForPlan::because($message) from being displayed to the user.

The message that gets displayed when the IneligibleForPlan exception gets thrown is hard-coded to "We were unable to update your subscription. Please contact customer support".

I think the line:

this.planForm.errors.set({plan: ["We were unable to update your subscription. Please contact customer support."]});

needs to be changed to:

this.planForm.errors.set({plan: response.body.plan});

or some similar fix.

Anyone know how to submit this as a real bug report?