I just created a profile for users, and wish to show the education details related to the logged-in user or another selected user.

for this, I created an education model for users and gave a proper relationship to it both the sides. im not able to get any data from the education table of loged in user or another user. i used foreach tag in blade file. please revview my code. thanks.

**Education Model**

```
class Education extends Model
{
    use HasFactory;

    protected $primaryKey = 'education_id';

    public function myusers()
    {
        return $this->belongsTo('App\Models\User','user_id','education_id');
    }

}

```

**User Model**

```
  public function myeducation()
    {
        return $this->hasMany('App\Models\Education','education_id','user_id');
    }

```

**Profile Controller**

```
   public function index()
    {

         $user = Auth::user();

          return view('candidate.profile',['user'=>$user,]);
    }

```

**Blade file**

```
 @foreach ($user->myeducation as $education)
                    <div>
                       {{  $education->school }}
                    </div>

                @endforeach

```

**Table Structure of Education and Users**

```
**Education Table**

{
        Schema::create('education', function (Blueprint $table) {
            $table->bigIncrements('education_id');
            $table->bigInteger('user_id');
            $table->string('school');
            $table->string('degree');
            $table->string('fieldOfStudy');
            $table->date('startDate');
            $table->date('endDate');
            $table->string('grade');
            $table->string('activities');
            $table->string('description');
            $table->timestamps();
        });
    }

```

**user table.**

```
        $table->increments('user_id');
        $table->bigInteger('role_id');
        $table->bigInteger('membership_id')->nullable();
        $table->string('firstname');
        $table->string('lastname');

```

**there is no error message, but just blank**

```
Table entries

 DB::table('education')
            'user_id' => '2',
            'school' => 'University of Bedfordshire',
            'degree' => 'MBA',

        ]);

 DB::table('users')->insert([
            'user_id' => '1',
            'role_id' => '1',
            'firstname' => 'Mohammed',
            'lastname' => 'Sabeel',
            .......
        ]);

        DB::table('users')
            ' user_id' => '2'
            'role_id' => '2',
            'firstname' => 'zahida',
            'lastname' => 'sabeel',
            .......
        ]);

```