• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups

Class not found

General Discussion
2
16
989
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C
    cmpengineers last edited by 12 Mar 2020, 08:24

    hello All

    im trying to create a package with controller and model but it seems the controller is not reconize the model ?

    even though i setup namespace correctly

    Screen Shot 2020-03-12 at 11.21.17 AM.png

    Screen Shot 2020-03-12 at 11.21.27 AM.png

    Screen Shot 2020-03-12 at 11.21.05 AM.png

    namespace packages\Drov\Address\Models;
    
    
    use Illuminate\Database\Eloquent\Model;
    
    class Area extends Model
    {
        //
    }
    
    
    <?php
    
    namespace Drov\Address\Http\Controllers;
    
    use Illuminate\Http\Request;
    use packages\Drov\Address\Models\Area;
    
    Route::post('address/area/save','Drov\Address\Http\Controllers\AddressController@store')->name('area.save');
    

    please advise

    Best regards

    1 Reply Last reply Reply Quote 0
    • R
      rahul last edited by 12 Mar 2020, 09:41

      Hello,

      Please run -

      composer dump-autoload
      

      command then check and make sure that you have used proper namespace.

      C 1 Reply Last reply 12 Mar 2020, 10:07 Reply Quote 0
      • C
        cmpengineers @rahul last edited by 12 Mar 2020, 10:07

        @rahul

        i already did it

        do i have to write the whole path

        like

        namespace packages\Drov\src\Address\Models;
        

        Or

        namespace packages\Drov\Address\Models;
        

        do we write 'src' ?

        Best regards

        1 Reply Last reply Reply Quote 0
        • R
          rahul last edited by 12 Mar 2020, 10:48

          Hi @cmpengineers

          Don' need to add src, second one is right.

          C 1 Reply Last reply 12 Mar 2020, 10:52 Reply Quote 0
          • C
            cmpengineers @rahul last edited by 12 Mar 2020, 10:52

            Dear @rahul

            thats what i did still showing me class not found ?

            namespace Drov\Address\Http\Controllers;
            
            use Illuminate\Http\Request;
            use packages\Drov\Address\Models\Area;
            
            <?php
            
            namespace packages\Drov\Address\Models;
            
            use Illuminate\Database\Eloquent\Model;
            
            class Area extends Model
            {
                //
            }
            
            

            Screen Shot 2020-03-12 at 1.50.40 PM.png

            is there another solution ?

            i did create the model manually not using php artisan does that cause not to work ?

            only the migration file i did it with php artisan

            Please advise ?

            Best regards

            1 Reply Last reply Reply Quote 0
            • R
              rahul last edited by 12 Mar 2020, 10:55

              Hi @cmpengineers

              You have used wrong namespace.

              Did your model is present like (Directory structure) -

              Packages->Drov->Address->Models->Area.

              Is that directory structure for your model.

              Thanks

              C 1 Reply Last reply 12 Mar 2020, 10:59 Reply Quote 0
              • C
                cmpengineers @rahul last edited by cmpengineers 12 Mar 2020, 11:02 12 Mar 2020, 10:59

                Dear @rahul

                yes that is correct , the error shows the

                <?php
                
                namespace Drov\Address\Http\Controllers;
                
                use Illuminate\Http\Request;
                use packages\Drov\Address\Models\Area; // when you want to use the model you put the whole path correct ?
                
                

                the error is from the AreaController where it cant see the model

                the full path to Area.php model

                packages/Drov/Address/src/Models

                best regards

                1 Reply Last reply Reply Quote 0
                • C
                  cmpengineers last edited by 12 Mar 2020, 11:04

                  Screen Shot 2020-03-12 at 2.03.36 PM.png

                  i have to insert Area in order to use it

                  $area = new Area();
                  
                  1 Reply Last reply Reply Quote 0
                  • R
                    rahul last edited by rahul 12 Mar 2020, 11:46 12 Mar 2020, 11:08

                    Hi @cmpengineers

                    Just use like -

                    \Area
                    
                    C 1 Reply Last reply 12 Mar 2020, 11:43 Reply Quote 0
                    • C
                      cmpengineers @rahul last edited by 12 Mar 2020, 11:43

                      @rahul

                      /Area 
                      

                      where do you mean ?

                      use packages\Drov\Address\Models\Area;
                      // like this
                      use packages/Drov/Address/Models/Area; // it does not. work error 
                      
                      1 Reply Last reply Reply Quote 0
                      • R
                        rahul last edited by rahul 12 Mar 2020, 11:45 12 Mar 2020, 11:45

                        @cmpengineers

                        I mean only -

                        use \Area;
                        
                        1 Reply Last reply Reply Quote 0
                        • C
                          cmpengineers last edited by 12 Mar 2020, 11:52

                          Dear @rahul

                          it doesnt work , error happens

                          Screen Shot 2020-03-12 at 2.52.27 PM.png

                          Screen Shot 2020-03-12 at 2.52.20 PM.png

                          Best regards

                          1 Reply Last reply Reply Quote 0
                          • R
                            rahul last edited by 12 Mar 2020, 11:54

                            Hello @cmpengineers

                            Push your code on git hub or git lab, and add me.
                            I need to check.

                            C 1 Reply Last reply 12 Mar 2020, 11:55 Reply Quote 0
                            • C
                              cmpengineers @rahul last edited by 12 Mar 2020, 11:55

                              Dear @rahul

                              finally its working i only needed to add App\

                              use App\packages\Drov\src\Models\Area;

                              Best regards

                              1 Reply Last reply Reply Quote 0
                              • C
                                cmpengineers last edited by 12 Mar 2020, 11:57

                                Dear @rahul

                                use App\packages\Drov\src\Models\Area; // this is the one that is working 
                                

                                i really appreciate it your effort

                                Best regards

                                R 1 Reply Last reply 12 Mar 2020, 11:58 Reply Quote 0
                                • R
                                  rahul @cmpengineers last edited by 12 Mar 2020, 11:58

                                  This post is deleted!
                                  1 Reply Last reply Reply Quote 0
                                  4 out of 16
                                  • First post
                                    4/16
                                    Last post