A
A
Artem2021-06-14 23:11:21
PHP
Artem, 2021-06-14 23:11:21

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');
    }
}

test:
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');
    }

controller:
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 question

Ask a Question

731 491 924 answers to any question