Support the ongoing development of Laravel.io →
Database Views Installation
Last updated 2 years ago.
0

From Larave 5 and up you need "use" every class, including models by their namespace.

....
use Models/Follow;

class User {
    ....
    ....

    public function follow() {
            return $this->hasMany('Follow');
    }
}

you can also define return $this->hasMany('Follow'); as return $this->hasMany(Follow::class);

0

astroanu said:

From Larave 5 and up you need "use" every class, including models by their namespace.

....
use Models/Follow;

class User {
   ....
   ....

   public function follow() {
           return $this->hasMany('Follow');
   }
}

you can also define return $this->hasMany('Follow'); as return $this->hasMany(Follow::class);

Class 'Models\Follow' not found it still can't see the class. Shown path is right, but stil..

0

Okay, solution was as @astroanu said. Every class what User model used, I added like:

use Events\Models\Follow;

and method to return:

public function follow() {
	return $this->hasMany(Follow::class);
}
0

Sign in to participate in this thread!

Eventy

Your banner here too?

edogaafx edogaafx Joined 16 Mar 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.