/** * 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'); }); }
protected static function boot() { parent::boot(); static::deleting(function ($category) { self::where('parents', 'LIKE', $category->parents . $category->id . '/%')->delete(); }); }
public static function boot() { parent::boot(); Category::creating(function ($category) { $category->slug = $category->generateSlug(); }); }
public static function boot() { parent::boot(); static::created(function ($topic) { SiteStatus::newReply(); }); }
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); }); }
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); }); }
public static function boot() { parent::boot(); static::creating(function (Order $order) { if (!$order->user_id && \Auth::check()) { $order->user_id = \Auth::user()->id; } }); }
/** * @return void * @static */ protected static function boot() { parent::boot(); static::validating(function (Tag $tag) { if (!$tag->slug) { $tag->slug = str_slug($tag->name); } }); }
/** * @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), '-')); } }); }
/** * 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; }); }
/** * 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'); }); }
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); }); }
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; } }); }
/* 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);
public static function boot() { parent::boot(); static::creating(function ($meta) { }); }