Created
November 24, 2013 05:24
-
-
Save crynobone/7623688 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Deposit extends OperationBaseModel { | |
protected $guarded = array(); | |
public static $rules = array( | |
'deposit_amount' => 'required', | |
'approval_status' => 'required' | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DepositObserver { | |
public function creating($model) { | |
// I would prefer to change from static to public method. | |
$deposit->reference_no = $this->generateReferenceNo(Config::get('referenceNo.depositPrefix')); | |
DB::table('deposit_status')->where('name', '=', 'Pending')->increment('record_count'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Deposit::observe(new UserReferenceObserver(Sentry::user())); | |
Deposit::observe(new DepositObserver); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class UserReferenceObserver { | |
protected $user; | |
public function __construct($user) { | |
$this->user = $user; | |
} | |
public function saving($model) { | |
$model->updated_by = $this->user->id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment