-
app/Models/User.php
Open in GitHubuse Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { public function projects() { return $this->belongsToMany(Project::class)->withPivot('owner'); } }
-
app/Http/Controllers/ProjectController.php
Open in GitHubuse App\Http\Requests\ProjectRequest; use App\Models\Project; class ProjectController extends Controller { // public function store(ProjectRequest $request) { $project = Project::create($request->only([ 'title', 'url', 'description', 'receive_email', 'slack_webhook', 'discord_webhook', 'custom_webhook', ])); $request->user()->projects()->save($project, ['owner' => true]); return redirect()->route('panel.projects.installation', $project); } // }
-
app/Models/Project.php
Open in GitHubuse Illuminate\Database\Eloquent\Model; class Project extends Model { // public function isOwner() { return $this->pivot->owner; } // }