Please consider the codes below.
Code1:
<?php
use App\User;
class SomeController {
public function getUsers()
{
return User::all();
}
}
Code2:
<?php
class SomeController {
public function getUsers()
{
return \App\User::all();
}
}
I got confused whether these two have that much impact to its performance. I know that the first way of coding seems really the better/nicer way but what if I just want to use the User
class just once on my Controller? Which is the better choice for single-used class?