Skip to content

Instantly share code, notes, and snippets.

@MCKLtech
Created September 13, 2019 14:52
Show Gist options
  • Save MCKLtech/33531725ed066dae32bbc1b0733d4d1d to your computer and use it in GitHub Desktop.
Save MCKLtech/33531725ed066dae32bbc1b0733d4d1d to your computer and use it in GitHub Desktop.
This gist demonstrates a method of creating a Spark User and setting up their initial Team
<?php
use App\Team;
use Laravel\Spark\Spark;
use Laravel\Spark\Interactions\Settings\Teams\CreateTeam;
//Create a User
$sparkUser = Spark::user();
$sparkUser->forceFill([
'name' => 'Joe Bloggs',
'email' => '[email protected]',
'password' => bcrypt('superPassword'),
'email_verified_at' => Carbon::now(),
'last_read_announcements_at' => Carbon::now(),
'trial_ends_at' => Spark::onlyTeamPlans() ? null : Carbon::now()->addDays(Spark::trialDays())
])->save();
//Create a Team
Spark::interact(CreateTeam::class, [
$sparkUser, [
'name' => 'My Team Name',
'slug' => 'my-slug',
]
]);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment