phplaravelrelationshiphas-one

Vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php:722


I got stuck with one to one relation Error View Facade\Ignition\Exceptions\ViewException Class 'App\App\User' not found (View: /var/www/html/project1/resources/views/pengajuan/datauser/index.blade.php) http://app.web/pengajuan/datauser

my User Model

public function dataUser()
{
  return $this->hasOne(App\DataUser::class);
}

my DataUser Model

public function User()
{
    return $this->belongsTo(App\User::class);
}

my controller

public function index()
{
    $datauser = DataUser::all();
    return view('pengajuan.datauser.index', compact('datauser'));
}

and my index view

@foreach ($datauser as $d)
 <td>{{$d->masa_penilaian}}</td>
 <td>{{$d->user->nama}}</td>
 <td>{{$d->nip}}</td>
 <td>{{$d->nuptk}}</td>
@endforeach

Can Help Me?

Thanks


Solution

  • Try DataUser::class instead of App\DataUser::class and User::class instead of App\User::class?