D
D
DTX2016-10-30 19:51:13
Laravel
DTX, 2016-10-30 19:51:13

Are namespaces related to folder structure?

Actually the question is in the header. But just in case, I'll clarify.
Laravel created a TestUser model for me in the app\ folder

namespace App;

use Illuminate\Database\Eloquent\Model;

class TestUser extends Model
{
    //
    protected $table = 'test';
}

You can use it like this:
use App\TestUser;

Route::get('/', function () {

  $t = TestUser::all();
  var_dump($t);
});

What needs to be done to move the model to another folder? Does the App\Folder\ClassName namespace mean that you need to load the file from App\Folder\ClassName?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
he he, 2016-10-30
@tosha_lol_daaa

Maybe learn the basics first?
Tyk ...
Ps: as far as I know, only when changing the structure of controllers it is required to connect the base everywhere, there should be no problems with the model.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question