Answer the question
In order to leave comments, you need to log in
Class not found from User Model?
Error
Class ' App\Models\Tests\test' not found
Used by laravel 8.
User model:
<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
public function createdTests()
{
return $this->hasMany(' App\Models\Tests\test', 'creator_id', 'id');
}
}
namespace App\Models\Tests;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\Tests\testViews;
use App\ILanguages;
class test extends Model
{
public function creator()
{
return $this->belongsTo('App\Models\User', 'creator_id', 'id');
}
auth()->user()->createdTests()->create([
'name' => "hello",
'desc' => "hello",
]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question