Skip to content

Instantly share code, notes, and snippets.

@mbernson
Created February 15, 2013 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbernson/4960430 to your computer and use it in GitHub Desktop.
Save mbernson/4960430 to your computer and use it in GitHub Desktop.
Idea for Activerecord callbacks in PHP.
<?php
class Event extends ActiveRecord\Model
{
static private $before_save = 'calculate_seats_available';
private function calculate_seats_available() {
$this->seats_available = $this->seats - $this->seats_taken;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment