Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

arslan2037's avatar

I am stuck in this error

I create a new Model, there is no relation in this Model file but i get this error, LogicException in Model.php line 2673: Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation

0 likes
16 replies
arslan2037's avatar

i get this error when i submit create form, data is inserted but this error is occured

arslan2037's avatar

here is model code <?php

            namespace App\Models;

        use Illuminate\Database\Eloquent\Model;

        class Team extends Model
        {
                protected $table = "company_teams";


        }
Snapey's avatar

Post all relevant code. In this case, the controller or whatever is using this model.

arslan2037's avatar

here is save method in controller

        public function saveCreateTeam(Request $request)
{

    $member_Ids =  implode(',', $request->members);
    
    $team = new Team;
    

// $team->members = json_decode($team->members);

    $team->company_id = $this->getCompanyID();
    $team->creator_id = Auth::user()->id;
    $team->name = $request->name;
    $team->team_lead = $request->team_lead;
    $team->members = $member_Ids;
    $team->status = $request->status;
    
    $team->save;
    
    Session::flash('flash_message', 'Team Data is Saved!');

    return redirect('user/employees/team/manage');      
} 
arslan2037's avatar

Routes -->

        Route::get('user/employees/team/create', 'TeamsController@createTeam');
        Route::post('user/employees/create-team', 'TeamsController@saveCreateTeam');
arslan2037's avatar

I have no relation in Model but it says.... error in Relation

bugsysha's avatar
bugsysha
Best Answer
Level 61

Change

$team->save;

to

$team->save();
1 like
bugsysha's avatar

p.s. why did you put this in Site Feedback channel? :D

arslan2037's avatar

@bugsysha not understand what you say? and thanks for help and @Snapey thanks to you as well, you solved my every problem here once again thanks both of you :)

bugsysha's avatar

This problem has nothing to do with Site Feedback channel. This is Laravel related issue and you've posted it in the channel for complaints about Laracasts website.

arslan2037's avatar

Ooh sorry... i forget to change the channel :)

Please or to participate in this conversation.