Example #1
0
 /**
  * Boot process.
  *
  * @return Void
  */
 protected static function boot()
 {
     parent::boot();
     static::addGlobalScope('order', function (Builder $builder) {
         $builder->orderBy('name', 'asc');
     });
 }
 /**
  * Boot process.
  *
  * @return Void
  */
 protected static function boot()
 {
     parent::boot();
     static::addGlobalScope('order', function (Builder $builder) {
         $builder->join('terms as t', 't.term_id', '=', 'term_taxonomy.term_id')->orderBy('t.name', 'asc');
     });
 }
Example #3
0
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($category) {
         self::where('parents', 'LIKE', $category->parents . $category->id . '/%')->delete();
     });
 }
Example #4
0
 public static function boot()
 {
     parent::boot();
     Category::creating(function ($category) {
         $category->slug = $category->generateSlug();
     });
 }
Example #5
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($topic) {
         SiteStatus::newReply();
     });
 }
Example #6
0
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($project) {
         $project->tasks()->delete();
         $project->invoices()->delete();
     });
 }
 /**
  * Boot process.
  *
  * @return Void
  */
 protected static function boot()
 {
     parent::boot();
     static::addGlobalScope('order', function (Builder $builder) {
         $builder->orderBy('comment_date', 'desc');
         $builder->where('comment_approved', 1);
     });
 }
Example #8
0
 public static function boot()
 {
     parent::boot();
     // Deleting an upload record should delete the file as well
     static::deleting(function ($upload) {
         $file = public_path() . '/' . $upload->path . '/' . $upload->filename;
         File::delete($file);
     });
 }
Example #9
0
 public static function boot()
 {
     parent::boot();
     static::creating(function (Order $order) {
         if (!$order->user_id && \Auth::check()) {
             $order->user_id = \Auth::user()->id;
         }
     });
 }
Example #10
0
 /**
  * @return void
  * @static
  */
 protected static function boot()
 {
     parent::boot();
     static::validating(function (Tag $tag) {
         if (!$tag->slug) {
             $tag->slug = str_slug($tag->name);
         }
     });
 }
Example #11
0
 /**
  * @return void
  * @static
  */
 protected static function boot()
 {
     parent::boot();
     static::validating(function (Author $author) {
         if (!$author->slug) {
             $author->slug = strtolower(trim(str_slug($author->name), '-'));
         }
     });
 }
Example #12
0
 /**
  * Find and use an unused non-sequential ID for a record, as part of a
  * model's creation. ID will be a 32-bit unsigned integer of 10 characters
  * in length.
  *
  * @return void
  */
 protected static function boot()
 {
     parent::boot();
     self::creating(function ($model) {
         do {
             $id = mt_rand(pow(10, 9), pow(2, 32) - 1);
         } while (self::find($id));
         $model->{$model->getKeyName()} = $id;
     });
 }
Example #13
0
 /**
  * Boot process.
  *
  * @return Void
  */
 protected static function boot()
 {
     parent::boot();
     $model = new static();
     if ($model->getPostType()) {
         static::addGlobalScope('post_type', function (Builder $builder) use($model) {
             $builder->where('post_type', $model->getPostType());
         });
     }
     static::addGlobalScope('order', function (Builder $builder) {
         $builder->orderBy('post_date', 'desc');
     });
 }
Example #14
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($expiration) {
         do {
             $token = sha1(uniqid() . time());
             $count = Expiration::where('token', $token)->count();
         } while ($count != 0);
         $expiration->token = $token;
         $minutes = intval(Setting::key('link_duration')->first()->value) > 0 ? intval(Setting::key('link_duration')->first()->value) : 60;
         $expiration->expiration = Carbon::now()->addMinutes($minutes);
     });
 }
Example #15
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($notification) {
         switch ($notification->type) {
             case 'new_prospect':
                 $prospect = Prospect::find($notification->type_id);
                 $user = User::find($notification->user_id);
                 Clickatell::send("Nuevo Interesado en " . $prospect->type . " - Nombre: " . $prospect->name . " Email: " . $prospect->email . " Tel.: " . $prospect->phone, $user->phone);
                 $data = ['name' => $prospect->name, 'email' => $prospect->email, 'phone' => $prospect->phone];
                 Mail::queue('emails.notify.new-prospect', $data, function ($message) use($user) {
                     $message->from('*****@*****.**', 'MLMfunnel');
                     $message->to($user->email, $user->full_name)->subject('Nuevo prospecto! - MLMfunnel');
                 });
                 break;
         }
     });
 }
Example #16
0
/* Session Start */
session_start();
/* Error reporting */
error_reporting(E_ALL);
/* set default timezone */
date_default_timezone_set('UTC');
define("ROOT_DIR", __DIR__ . "/../");
require_once ROOT_DIR . "vendor/autoload.php";
require_once ROOT_DIR . "database/Connection.php";
require_once ROOT_DIR . "core/config.php";
require_once ROOT_DIR . "core/Response.php";
require_once ROOT_DIR . "core/io.php";
require_once ROOT_DIR . "core/Validator.php";
require_once ROOT_DIR . "core/Flash.php";
require_once ROOT_DIR . "core/Middleware.php";
require_once ROOT_DIR . "core/Upload.php";
require_once ROOT_DIR . "core/Paginator.php";
require_once ROOT_DIR . "core/Helpers.php";
//
$app['middleware'] = new Middleware();
// Loading Models
require_once ROOT_DIR . "models/Model.php";
$con = new Connection($config['DB_HOST'], $config['DB_USER'], $config['DB_PASS'], $config['DB_NAME']);
Model::boot($con->getConnction());
$app["flash"] = new Flash();
$app["flash"]->start();
// Setup Twig Template Engine
$loader = new Twig_Loader_Filesystem(ROOT_DIR . 'templates');
$app["template"] = new Twig_Environment($loader, array());
$app["template"]->addGlobal('config', $config);
Example #17
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($meta) {
     });
 }