:::: MENU ::::
Browsing posts in: Blog

Seeding Active Users in Laravel Spark

In case you didn’t know, Laravel has a package that provides scaffolding to get your next project up and running really quickly called Spark.

I’ve been using it for a while to build a little project that I’ll hopefully one day release.

Tonight I was working on trying to seed users to the database and have them already recognised as active users by Spark. I though this meant I’d be providing each seeded user with stripe information – a task I wasn’t looking forward to automating.

After Googling for a bit, jumping onto Laracasts forums and onto Slack (I was moments away from installing IRC), I discovered that I should just look at things for myself.

It turns out (unless I’m completely wrong) that all I had to do to seed active users for Laravel Spark was make a factory for the Subscription model that is part of Spark.

$factory->define(Laravel\Spark\Subscription::class, function (Faker\Generator $faker) {
    return [
        'user_id' => '1',
        'name' => 'default',
        'stripe_id' => '',
        'stripe_plan' => 'basic-yearly',
        'quantity' => '1',
        'trial_ends_at' => null,
        'ends_at' => null
    ];
});

After that, it was just a matter of throwing that factory into my DatabaseSeeder.php

factory(App\User::class, 25)
    ->create([
        'current_billing_plan' => 'basic-yearly'
    ])
    ->each(function ($user){
        factory(Laravel\Spark\Subscription::class)
            ->create(['user_id' => $user->id]);
});

So far it seems that I needn’t worry about the stripe_id columns, as it seems to work as is.

There is probably a better way to do this – if there is please let me know!


Why I don’t blog

There’s a good reason I’ve never been able to maintain a blog. I don’t often have a lot to write about.

For example, this post was drafted on October 25th 2016. Never let me have a website.. seriously


Digital Footprints

At the hospital when my youngest daughter was born, I swear there were Apple and Samsung reps in the hallway trying to sign her to a brand, well at least it feels that way sometimes. I’ve received some odd looks from people when they ask what my daughters like to use on an iPad and I tell them that they don’t have one, and won’t unless it is compulsory for school. I survived my early childhood without a device, and I’m sure they will survive theirs.

However, I digress. I’m really writing about digital footprints. Teaching kids about being cyber-smart isn’t the easiest job in the world, but it has to be done.

Continue Reading


Coding and Me

I’m actually really nervous to write about coding. I realise very few people will actually read this, so I suppose I shouldn’t stress, but all the same I can’t seem to help it. I know that I certainly won’t have anything amazing to say like some of the people I follow on Twitter!

amiga_500_system_by_amiga1200

I first started programming when I was very young. We got our first computer – an Amiga 500 – in 1991. I would have been 6 at the time.

Continue Reading


Shooting the Moon

moon rise

I don’t think I’ve said it yet on this blog – I love space. I love the moon. I am envious that people have walked on it and that I never will, but I also know I would probably never choose to enter space of my own accord. I like oxygen too much. I have to content myself with photographs and text when it comes to space.

I’ve gone through and found a few photos of my foray into photographing the moon, and thought I’d enlighten you, my reader, on the the changes I have undertaken in this pursuit.

Continue Reading


The Benji Thing (Part 2)

Back Home!


Benji made it back home!

After some frantic Googling last night to try to find a backup Benji, all our worries were in vain.

Thankfully, our lovely daughter managed to drop him in the Post Office, where he was safely looked after in the magical land of ‘Lost and Found’

Happily reunited, Benji will never leave the house again.

For what it’s worth I found him for sale in Turkey and Taiwan -the only online shops that seem to have him in stock (though I am relying on Google translate for that knowledge).



The Benji Thing

Benji



Benji…

This is Benji.

Or at least a stock photo version of him.

Benji was gifted to us by someone from work back in 2013 when we were expecting the twins. One of our girls loves him.

Yesterday we had a trip to the dentist, and as suggested by Peppa Pig, Benji came along for the ride. At some point between leaving the dentist and arriving home later that afternoon, Benji had vanished. A very distraught 3.5 year old went to bed, after giving me the instruction “Never stop looking for him, ok?”

Needless to say, I feel like crap.

God speed Benji, wherever you may be.


Hello world!

Hi!

I’m Michael and this is my corner of the internet. I’m a husband, a father to three beautiful girls, and I am a jack-of-all-trades geek. I’ve started many blogs over the years, but because I never had a ‘niche’, I never bothered maintaining them. This one I plan to, mostly because it has no niche.

I like photography, computers, coding, graphic design, music, video games, my family, my job… too many things to maintain a simple blog on one thing.

So here is my collective cruft, here for your reading pleasure.

Enjoy