错误类不存在

时间:2015-07-12 04:11:07

标签: php laravel eloquent laravel-5

我得到的错误是

ReflectionException in compiled.php line 1082:
Class App\Repositories\Frontend\Lewp does not exist

以下是较长的错误消息

in compiled.php line 1082
at ReflectionParameter->getClass() in compiled.php line 1082
at Container->getDependencies(array(object(ReflectionParameter)), array()) in compiled.php line 1074
at Container->build('App\Http\Controllers\Frontend\FrontendController', array()) in compiled.php line 1012
at Container->make('App\Http\Controllers\Frontend\FrontendController', array()) in compiled.php line 1550
at Application->make('App\Http\Controllers\Frontend\FrontendController') in compiled.php line 8791
at ControllerDispatcher->makeController('App\Http\Controllers\Frontend\FrontendController') in compiled.php line 8780
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Frontend\FrontendController', 'lewp') in compiled.php line 7759
at Route->runWithCustomDispatcher(object(Request)) in compiled.php line 7730
at Route->run(object(Request)) in compiled.php line 7383
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9455
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9437
at Pipeline->then(object(Closure)) in compiled.php line 7384
at Router->runRouteWithinStack(object(Route), object(Request)) in compiled.php line 7372
at Router->dispatchToRoute(object(Request)) in compiled.php line 7357
at Router->dispatch(object(Request)) in compiled.php line 2066
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9455
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 2637
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12699
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 11348
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12437
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 12376
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 2687
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9447
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9437
at Pipeline->then(object(Closure)) in compiled.php line 2013
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 1999
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\projects\lewp\public\index.php') in server.php line 21

我并不肯定我已正确设置所有内容。一直在努力尝试正确地设置这个设置,并且真正在努力解决所有事情彼此之间的关系。

<?php namespace App\Http\Controllers\Frontend;

use App\Http\Controllers\Controller;
use App\Repositories\Frontend\Lewp as Lewp;

/**
 * Class FrontendController
 * @package App\Http\Controllers
 */
class FrontendController extends Controller {
    protected $lewp;

    function __construct(Lewp $lewp) {
        $this->lewp = $lewp;
    }
    /**
     * @return \Illuminate\View\View
     */
    public function index()
    {
        return view('frontend.index');
    }

    /**
     * @return \Illuminate\View\View
     */
    public function macros()
    {
        return view('frontend.macros');
    }
    public function post()
    {
        return view('frontend.post');
    }
    public function exterior()
    {
        return view('frontend.exterior');
    }
    public function submit()
    {
        return view('frontend.submit');
    }
    public function self()
    {
        return view('frontend.self');
    }
    public function lewp($name)
    {
        if(strlen($name) == 0)
        {
            return view('frontend.index');
        }
        $lewp = $this->lewp->getLewpByName($name);
        return view::make('frontend.lewp', array('lewp' => $lewp));
    }
}

这是模型

<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Lewp extends Model
{
    use SoftDeletes;
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'lewps';

    /**
     * The attributes that are not mass assignable.
     *
     * @var array
     */
    protected $guarded = ['id'];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = [];

    /**
     * For soft deletes
     *
     * @var array
     */
    protected $dates = ['deleted_at'];   
}

这是存储库

<?php namespace App\Repositories\Frontend;

use App\Lewp;
use App\Exceptions\GeneralException;


/**
 * Class EloquentUserRepository
 * @package App\Repositories\Lewp
 */
class EloquentLewpRepository implements LewpContract {

    public function __construct(Lewp $lewpRepository) 
    { 
        $this->lewpRepository = $lewpRepository; 
    }

    /**
     * @param $id
     * @return \Illuminate\Support\Collection|null|static
     * @throws GeneralException
     */
    public function findOrThrowException($id) {
        $lewp = Lewp::find($id);
        if (! is_null($lewp)) return $lewp;
        throw new GeneralException('That lewp does not exist.');
    }

    /**
     * @param $data
     * @param bool $provider
     * @return static
     */

    public function create($data) {
        $lewp = Lewp::create([
            'name' => $data['name'],
            'title' => $data['title'],
            'text' => $data['text'],
            'sidebar' => $data['sidebar'],
            'submission_text' => $data['submission_text'],
            'type' => $data['type'],
            'content_options' => $data['content_options'],
            'link_button_text' => $data['link_button_text'],
            'text_button_text' => $data['text_button_text'],
            'options' => $data['options'],
            'comment_sort_method' => $data['comment_sort_method'],
            'hide_comment_scores' => $data['hide_comment_scores'],
            'header_mouseover-text' => $data['header_mouseover-text']
        ]);

        return $lewp;
    }

    public function searchLewpsByName($term) {
        $lewp = Lewp::where('name', 'LIKE', $term)->get();

        return $lewp;
    }

    public function getLewpByName($lewpname) {
        $lewp = Lewp::where('name', '=', $lewpname)->first();

        return $lewp;
    }

    public function getLewpId($lewpname) {
        $lewp = Lewp::select(array('id')->where('name', '=', $lewpname)->first();

        return $lewp;
    }

}

2 个答案:

答案 0 :(得分:1)

在课程Lewp中修复:

namespace App\Repositories\Frontend;

答案 1 :(得分:0)

如果命名空间正确并且问题仍然存在 尝试在流浪汉中运行$composer dump-autoload