Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0

It's probably just an issue with your namespace.

Check out this example to help you pinpoint the issue:

location: app/PurpleGriffin/ELearningCourses

namespace App\PurpleGriffin\ELearningCourses;

class ELearningCoursesClass {
      public function convertPrice(){
              //convert that price here yo
      }
}

location: app/controllers

namespace App\Controllers;

use App\PurpleGriffin\ELearningCourses\ELearningCoursesClass;

class CoursesController {

    public function getCourse()
    {
        $course = new ELearningCoursesClass();
    }
}

Remember, you should call them from the root namespace. e.g:

 $classVar = new class(); will become $classVar = new \class(); 

after all is said and done, you need to run your composer dump-autoload to get everything recognized.

Let me know if this helps.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.