mardi 11 août 2020

Laravel I added morphmany SQLSTATE[42S22]: Column not found: 1054 Unknown column 'staff.staff_id' in 'field list'

I store the data correctly but when I try to get a data in edit function it shows me this error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'staff.staff_id' in 'field list' (SQL: select users.*, staff.staff_id as pivot_staff_id, staff.user_id as pivot_user_id, staff.staff_type as pivot_staff_type, staff.role as pivot_role, staff.created_at as pivot_created_at, staff.updated_at as pivot_updated_at from users inner join staff on users.id = staff.user_id where staff.staff_id in (2) and staff.staff_type = App\Models\Investor)

//investor relationship
     public function staff()
    {
        return $this->morphToMany(User::class, 'staff')
                    ->withPivot(['role'])
                    ->withTimestamps();
    }
//user relationship

    public function investors()
    {
        return $this->morphedByMany(Investor::class, 'staff');
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire