public static function boot()
 {
     parent::boot();
     static::creating(function ($obj) {
         $fullAddr = implode(', ', array_map(function ($f) use($obj) {
             return $obj->{$f};
         }, ['address', 'city', 'state', 'postal_code', 'country']));
         try {
             $geocoded = App::make('geocoder')->geocode($fullAddr);
             $obj->latitude = $geocoded->getLatitude();
             $obj->longitude = $geocoded->getLongitude();
         } catch (\Exception $e) {
             // swallow error and leave lat/lng blank
         }
     });
     // static::created(function($obj) {
     //     $obj->campaigns()->sync([Campaign::current()->id]);
     //     foreach( CallToAction::all() as $cta ) {
     //         $data = [
     //             'organization_id' => $obj->id,
     //             'call_to_action_id' => $cta->id,
     //             'participating' => true,
     //         ];
     //         OrganizationCallToAction::create($data);
     //     }
     // });
 }
 public static function boot()
 {
     parent::boot();
     static::creating(function ($obj) {
         $obj->status = 'active';
     });
 }
Exemplo n.º 3
0
 public function __construct(array $attrs = array(), array $options = [])
 {
     parent::__construct($attrs);
     // always pre-set status, so it will be set and pass validation even
     // if the form doesn't present the field (i.e. frontend)
     $this->status = 'confirmed';
     $this->configureValidations($options);
     static::saving(function ($obj) {
         unset($obj->email_confirmation);
     });
 }
 public function __construct(array $attrs = array())
 {
     parent::__construct($attrs);
     if ($campaign = Campaign::current()) {
         $this->campaign_id = $campaign->id;
     }
     $this->configureValidations();
     static::saving(function ($obj) {
         unset($obj->email_confirmation);
     });
 }
Exemplo n.º 5
0
 public static function boot()
 {
     parent::boot();
     static::saving(function ($obj) {
         if (isset($obj->password)) {
             if ('' != $obj->password && null != $obj->password) {
                 $obj->password_hash = Hash::make($obj->password);
             }
         }
         unset($obj->password);
         unset($obj->password_confirmation);
     });
 }