7 months ago

Register a Team to a Post

Posted 7 months ago by honeyBear

Currently, I am trying to register Team to a Post. Team belongstoMany Post and Post belongstoMany Team. But the data is not stored into the pivot table, am I doing it the wrong way? Below is my code. Assume that user has already created his/her Team before registering his/her Team to desire Post which is a tournament event.

(blade file posts.show)

<form method="post" action="/team/register">
   <a class="btn btn-outline-dark btn-sm">
          {{ __('Register') }}

(routes file)

Route::post('/team/register', '[email protected]');

([email protected])

    public function register()
        $post = Post::find('id', '=', $post->id);
        $team = Team::where('id', '=', $team->id);

        return redirect()->back()->with('success', 'Team Registered');

([email protected])

    public function show(Post $post, Bracket $bracket)
        return view('posts.show', [
            'post' => $post,
            'bracket' => $bracket,

(pivot table migration file)

    public function up()
        Schema::create('post_team', function (Blueprint $table) {

Please sign in or create an account to participate in this conversation.