Class ‘AppmodelsTest’ not found when try to access model

I am try to learn laravel framework.

when i am try to use model at that time i got some error.

In my test controller

 <?php 
        namespace AppHttpControllers;

        use AppmodelsTest;

        class TestController extends Controller {

            public function __construct()
            {
                $this->middleware('guest');
            }

            public function editData($id) {
                $result = DB::select('select * from users where id = ?', array($id));
                $data['data'] = $result[0];
                return view('myview', $data);
            }

       }
?>

and in my model

model path is app/models/Test.php

model name is Test.php

<?php
use IlluminateDatabaseEloquentModel;
class Test extends Model {
    protected $table = 'users';
    public static function getMyData(){

         $user = Test::find();

    }
}
?>

Output :

FatalErrorException in TestController.php line 56:
Class 'AppmodelsTest' not found

I am also try this command.

composer dump-autoload

But is not working.

Answer

Your Test model isn’t in any namespace at all. You would need to reference it by:

use Test;

or:

Test::getMyData();

Or just put it in the namespace you try to reference it now:

<?php
namespace Appmodels;

use IlluminateDatabaseEloquentModel;
class Test extends Model {
    protected $table = 'users';
    public static function getMyData(){
        $user = Test::find();
    }
}
?>