定制 fox-run-holdings/laravel-teams 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fox-run-holdings/laravel-teams

Composer 安装命令:

composer require fox-run-holdings/laravel-teams

包简介

A Laravel package for team management with invitations and role-based access control

README 文档

README

Latest Version on Packagist Total Downloads License

A comprehensive Laravel package for team management with invitations and role-based access control.

Features

  • Team Management: Create, edit, and manage teams
  • Role-Based Access Control: Owner, Admin, and Member roles
  • Team Invitations: Send and manage team invitations
  • Team Switching: Switch between teams seamlessly
  • Livewire Components: Modern, reactive UI components
  • Soft Deletes: Safe team deletion with soft deletes
  • Pagination: Built-in pagination for team listings

Installation

Prerequisites

This package requires Flux UI Pro to be installed in your Laravel application. The views and components use Flux UI Pro components.

If you haven't installed Flux UI Pro yet, please install it first:

composer require flux-ui/flux-ui-pro

1. Install the package

composer require fox-run-holdings/laravel-teams

2. Publish the configuration and views

php artisan vendor:publish --provider="FoxRunHoldings\LaravelTeams\Providers\TeamsServiceProvider"

3. Run the migrations

php artisan migrate

4. Add team relationships to your User model

Add the following methods to your App\Models\User model:

<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use FoxRunHoldings\LaravelTeams\Models\Team;
use FoxRunHoldings\LaravelTeams\Models\TeamInvitation;

class User extends Authenticatable
{
    // ... existing code ...

    /**
     * Get the teams that the user belongs to.
     */
    public function teams(): BelongsToMany
    {
        return $this->belongsToMany(Team::class, 'team_user')
            ->withPivot('role')
            ->withTimestamps();
    }

    /**
     * Get the team invitations for the user.
     */
    public function Invitations(): HasMany
    {
        return $this->hasMany(TeamInvitation::class, 'email', 'email');
    }

    /**
     * Get the current team of the user.
     */
    public function currentTeam()
    {
        return $this->belongsTo(Team::class, 'current_team_id');
    }

    /**
     * Check if the user has teams.
     */
    public function HasTeams(): bool
    {
        return $this->teams()->exists();
    }

    /**
     * Get the user's role in a specific team.
     */
    public function role($team_id): string
    {
        $team = $this->teams()->where('team_id', $team_id)->first();
        return $team ? $team->pivot->role : 'member';
    }

    /**
     * Get the user's initials for avatar display.
     */
    public function initials(): string
    {
        $name = explode(' ', $this->name);
        $initials = '';
        
        if (count($name) >= 2) {
            $initials = strtoupper(substr($name[0], 0, 1) . substr($name[1], 0, 1));
        } else {
            $initials = strtoupper(substr($this->name, 0, 2));
        }
        
        return $initials;
    }
}

Usage

Facade Usage

The package provides a facade for easy access to team functionality:

use FoxRunHoldings\LaravelTeams\Facades\Teams;

// Create a team
$team = Teams::create([
    'name' => 'My Team',
    'owner_id' => auth()->id(),
]);

// Find a team
$team = Teams::find(1);

// Create an invitation
$invitation = Teams::invite($team->id, 'user@example.com', 'member');

// Accept an invitation
Teams::acceptInvitation($invitation->id);

// Switch to a team
Teams::switchTeam($team->id);

// Get current team
$currentTeam = Teams::getCurrentTeam();

Livewire Components

The package provides several Livewire components that you can use in your views:

Team Invitations

<livewire:teams.invitations />

Team Management

<livewire:teams.manage />

Team Members

<livewire:teams.members />

Team Switcher

<livewire:teams.switcher />

Routes

Add the following routes to your routes/web.php:

Route::middleware(['auth'])->group(function () {
    Route::get('/teams', function () {
        return view('teams.manage');
    })->name('teams');
    
    Route::get('/teams/members', function () {
        return view('teams.members');
    })->name('teams.members');
    
    Route::get('/teams/invitations', function () {
        return view('teams.invitations');
    })->name('teams.invitations');
});

Configuration

The package configuration is published to config/teams.php. You can customize:

  • User model class
  • Available team roles
  • Invitation statuses
  • Pagination settings
  • Route configuration

Database Structure

The package creates the following tables:

  • teams - Team information
  • team_user - Many-to-many relationship between teams and users
  • team_invitations - Team invitations
  • Adds current_team_id to the users table

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

This package is open-sourced software licensed under the MIT license.

Support

For support, please open an issue on GitHub or contact us at info@foxrunholdings.com.

fox-run-holdings/laravel-teams 适用场景与选型建议

fox-run-holdings/laravel-teams 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 fox-run-holdings/laravel-teams 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fox-run-holdings/laravel-teams 我们能提供哪些服务?
定制开发 / 二次开发

基于 fox-run-holdings/laravel-teams 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-11