1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

laravel4でモデルクラスのコンストラクタを拡張したいとき

Last updated at Posted at 2013-12-11

書き方

MyModel.php
   public function __construct($attributes = array(), $exists = false)
   {
      parent::__construct($attributes, $exists);

      // ここに自分のコードを書く
   } 

補足

継承する実際の処理は
https://github.com/laravel/framework/blob/master/src/Illuminate/Database/Eloquent/Model.php
の下記の部分。

Model.php
public function newInstance($attributes = array(), $exists = false)
1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?