Class Not Found in Laravel 5

1

I have this Controller in Laravel 5 .

HomeController.php

<?php namespace App\Http\Controllers;

    use View;
    use App\Portfolio;
    use App\Cliente;

    class HomeController extends Controller {

    public function getIndex(){

        # PORTFOLIO - Separado em Três Partes no Owl Carousel
        $portfolio['um']    = Portfolio::take(5)
                              ->whereStatus(1)
                              ->get();

        $portfolio['dois']  = Portfolio::skip(5)
                              ->whereStatus(1)
                              ->take(5)
                              ->get();

        $portfolio['tres']  = Portfolio::skip(10)
                              ->whereStatus(1)
                              ->take(5)
                              ->get();

        return view('frontend.home')
               ->withPortfolio($portfolio);
    }

}

It makes an extends of Controller . And within that Controller I created a function.

<?php namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;

abstract class Controller extends BaseController {

    use DispatchesCommands, ValidatesRequests;

    # Nome do Cliente no Portfolio
    static function NomeCliente($cliente){
        $explode    = explode(' ', $cliente);
        $varCliente = $explode[0].' <span>'.$explode[1].'</span>';

        return $varCliente;
    }

}

View

<h2>{!! Controller::NomeCliente($item->client->nome_fantasia) !!}</h2>

Then in View I call this function by Controller , as I always did in Laravel 4.2 .

But now this error happens:

  

Class 'Controller' not found

What's wrong or missing?

I've created a new controller, called NewController.php just for testing. Even in View when I call it, it also says it was not found.

Resolution

I was able to resolve it as follows:

Placing the full Controller path in View . Ex:

{!! App\Http\Controllers\URLController::Link('quem-somos') !!}

    
asked by anonymous 24.08.2015 / 18:59

1 answer

1

Resolution

I was able to resolve it as follows:

Placing the full Controller path in the View. Ex:

{!! App\Http\Controllers\URLController::Link('quem-somos') !!}

    
02.09.2015 / 13:29