---
title: "Creating teams — Teams for Laravel | Roundly"
description: "Create a team and seat its owner with Teams::create(), create rows directly when you need to, and query teams with scopes and relations."
url: https://roundly-consulting.com/open-source/docs/teams-for-laravel/creating-teams
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Teams for Laravel](https://roundly-consulting.com/open-source/docs/teams-for-laravel.md)

# Creating teams

Create a team from a CreateTeamData DTO through the facade — it seats the owner and is recorded by Teams::fake():

```php
use RoundlyConsulting\Teams\DataTransferObjects\CreateTeamData;
use RoundlyConsulting\Teams\Facades\Teams;

$team = Teams::create(new CreateTeamData(
    name: 'Acme Inc',
    isPublic: false,           // default false
    owner: $user,              // default null — added as a member with the owner role
    meta: ['plan' => 'pro'],   // default []
));
```

With an owner, the team is stamped with the owner morph and the owner is added as a member with the roles.owner role (owner by default). Without one, the team has no owner and no initial member. Everything after creation goes through Teams::for($team) — see The Teams facade.

## Creating a team directly

Team is a regular Eloquent model, so Team::create() works too — it creates the row only, without an owner member:

```php
use RoundlyConsulting\Teams\Models\Team;

$team = Team::create([
    'name' => 'Acme Design',
    'is_public' => false,
    'meta' => ['pricing' => 'per_member'],
]);

// Scopes
Team::query()->public()->get();            // only public teams
Team::query()->withMember($user)->get();   // teams the model belongs to
```

## Team relations

```php
$team->members();        // HasMany<Member>
$team->invites();        // HasMany<Invite>
$team->joinRequests();   // HasMany<JoinRequest>
$team->teamRoles();      // HasMany<TeamRole> — per-team role overrides
$team->owner();          // MorphTo — the owning model (nullable)

$team->name;             // string
$team->is_public;        // bool
$team->meta;             // Collection, cast from JSON
```

## Facade lookups

```php
Teams::roles()->find('admin');   // ?Role
Teams::roles()->all();           // array<string, Role>
Teams::permissions()->all();     // array<string, Permission>
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/teams-for-laravel.md)
