This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
You can install the package via composer:
composer require hexafuchs/laravel-project-teamsYou can publish and run the migrations with:
php artisan vendor:publish --tag="project-teams-migrations"
php artisan migrateNote
If you like, you can make the team names unique. Just add the unique directive to the name column in the migration. You can also add this later, just create a new migration and add the unique condition to the name column.
You can publish the config file with:
php artisan vendor:publish --tag="project-teams-config"Add the team member trait to your user class, e.g.:
app\Models\User.php
use Hexafuchs\Team\Traits\TeamMember;
class User extends Authenticatable
{
use ..., TeamMember;
}Make sure you published the configuration. Then go into the configuration and update the model class, e.g.:
config/teams.php
return [
'models' => [
'user' => \App\Models\User::class,
]
];To add a model to be owned by your team, add the Ownable trait to it, e.g.:
app\Models\SomeItem.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Hexafuchs\Team\Traits\Ownable;
class SomeItem extends Model {
use Ownable;
}If you wanna create a new relation that can be called from the Team model, you should first extend the team model in your project, e.g.:
app\Models\Team.php
<?php
namespace App\Models;
use Hexafuchs\Team\Team as Model;
class Team extends Model {
}Update the config file to use your newly created model, e.g.:
return [
'models' => [
'team' => \App\Models\Team::class,
]
];Now add your relation, e.g.:
class Team extends Model {
public function ownedItems(): MorphToMany
{
return $this->morphedByMany(\App\Models\SomeItem, 'ownable');
}
}composer testStart setting up workbench if it is not already available under /workbench. The more you publish the better. Choose
the .env file.
php vendor/bin/testbench workbench:installPublish all required resources. (Remember to republish the resources if you change them.)
php vendor/bin/testbench vendor:publish --tag="project-teams-config"
php vendor/bin/testbench vendor:publish --tag="project-teams-migrations"Let's migrate.
php vendor/bin/testbench migrateIf you wanna execute some command, call php vendor/bin/testbench instead of the typical php artisan.
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.