Skip to content

Instantly share code, notes, and snippets.

@MCKLtech
Created September 13, 2019 14:50
Show Gist options
  • Save MCKLtech/e9696aa54cb71bbb923347acc75bcc85 to your computer and use it in GitHub Desktop.
Save MCKLtech/e9696aa54cb71bbb923347acc75bcc85 to your computer and use it in GitHub Desktop.
This gist demonstrates a method of adding a Spark User to an existing Spark Team
<?php
use App\Team;
use Laravel\Spark\Spark;
use Laravel\Spark\Contracts\Interactions\Settings\Teams\AddTeamMember;
//Get a Spark User
$sparkUser = Spark::user()->where('email', '[email protected]')->first();
//TODO: Check user exists
//Get a Spark Team
$team = Team::where('name', 'myGreatTeam')->first();
//TODO: Check Team exists
//The role 'member' is a default in Spark.
Spark::interact(AddTeamMember::class, [
$team, $sparkUser, 'member'
]);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment