laravel Model 使用绑定方式调用App::bind

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jmlxx/article/details/80523647
App::bind('dean', function($app) {

    return new Dean;

});

App::bind('comment', function($app) {

    return new Comment;

});

先绑定

    protected $oDean;

    protected $oComment;

    public function __construct(){

        $this->oDean = App::make('dean');

        $this->oComment = App::make('comment');

    }

然后制造

   public function __construct(){

        parent::__construct();

    }

继承父类

$this->oDean -> deleteDean($id)

调用

错误页面设置

/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/

App::error(function(Exception $exception, $code)
{
    Log::error($exception);
    if(!Config::get('app.debug')){
        if($code == '404'){
            return View::make('error_404');
        }
    }
});

/*
|--------------------------------------------------------------------------
| Maintenance Mode Handler
|--------------------------------------------------------------------------
|
| The "down" Artisan command gives you the ability to put an application
| into maintenance mode. Here, you will define what is displayed back
| to the user if maintenance mode is in effect for the application.
|
*/

App::down(function()
{
    return Response::make("Be right back!", 503);
});

猜你喜欢

转载自blog.csdn.net/jmlxx/article/details/80523647