Skip to content
This repository has been archived by the owner on Feb 18, 2020. It is now read-only.

Commit

Permalink
Namespaces no PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardias committed Sep 8, 2015
1 parent ee438f8 commit ac55d37
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 206 deletions.
7 changes: 7 additions & 0 deletions app/Http/Controllers/ArtigosController.php
@@ -1,5 +1,12 @@
<?php

namespace App\Http\Controllers;

use App\Models\Artigo;
use Input;
use Redirect;
use View;

class ArtigosController extends Controller {

public function getIndex()
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Controller.php
@@ -1,5 +1,7 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
Expand Down
8 changes: 8 additions & 0 deletions app/Http/Controllers/HomeController.php
@@ -1,5 +1,13 @@
<?php

namespace App\Http\Controllers;

use App\Models\Artigo;
use Auth;
use Input;
use Redirect;
use View;

class HomeController extends Controller {

public function getIndex()
Expand Down
7 changes: 7 additions & 0 deletions app/Http/Controllers/UsuariosController.php
@@ -1,5 +1,12 @@
<?php

namespace App\Http\Controllers;

use App\Models\Usuario;
use Input;
use Redirect;
use View;

class UsuariosController extends Controller
{
public function getIndex()
Expand Down
8 changes: 6 additions & 2 deletions app/Http/Models/Artigo.php
@@ -1,10 +1,14 @@
<?php

class Artigo extends Eloquent
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Artigo extends Model
{
// Relacionamento com usuários
public function usuario()
{
return $this->belongsTo('Usuario');
return $this->belongsTo('App\Models\Usuario');
}
}
7 changes: 5 additions & 2 deletions app/Http/Models/Usuario.php
@@ -1,11 +1,14 @@
<?php

namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class Usuario extends Eloquent implements AuthenticatableContract, CanResetPasswordContract {
class Usuario extends Model implements AuthenticatableContract, CanResetPasswordContract {

use Authenticatable, CanResetPassword;

Expand Down Expand Up @@ -43,6 +46,6 @@ public function getAuthPassword()
// Relacionamento com artigos
public function artigos()
{
return $this->hasMany('Artigo');
return $this->hasMany('App\Models\Artigo');
}
}
2 changes: 1 addition & 1 deletion app/Providers/RouteServiceProvider.php
Expand Up @@ -14,7 +14,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @var string
*/
protected $namespace = null;
protected $namespace = 'App\Http\Controllers';

/**
* Define your route model bindings, pattern filters, etc.
Expand Down
4 changes: 1 addition & 3 deletions composer.json
Expand Up @@ -17,9 +17,7 @@
},
"autoload": {
"classmap": [
"database",
"app/Http/Controllers",
"app/Http/Models"
"database"
],
"psr-4": {
"App\\": "app/"
Expand Down

0 comments on commit ac55d37

Please sign in to comment.