Skip to content

Commit

Permalink
Update AdvancedModel.php
Browse files Browse the repository at this point in the history
  • Loading branch information
lesichkovm committed Jul 15, 2018
1 parent cf1419d commit a03b40b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/AdvancedModel.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

class AdvancedModel extends \Illuminate\Database\Eloquent\Model {

protected $primaryKey = 'Id';
public $incrementing = false;
public $timestamps = true;
Expand Down Expand Up @@ -36,23 +37,25 @@ public static function boot() {
return;
}
if ($model->useUniqueId) {
$model->{$model->getKeyName()} = $model->generateUniqueId();
if (is_null($model->{$model->getKeyName()})) {
$model->{$model->getKeyName()} = $model->generateUniqueId();
}
return;
}
});
}

public static function chunks($perChunk) {
$total = static::count();
$numChunks = ceil($total / $perChunk);
return $numChunks;
}

public static function getConnName() {
$o = new static;
return $o->connection;
}

public static function getTableName() {
return (new static)->getTable();
}
Expand Down

0 comments on commit a03b40b

Please sign in to comment.