1. 程式人生 > >laravel Model 使用繫結方式呼叫App::bind

laravel Model 使用繫結方式呼叫App::bind

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); });