Improvements upon the import routine.

This commit is contained in:
James Cole 2014-09-14 21:06:48 +02:00
parent 62ba40b687
commit 19402b9022
3 changed files with 416 additions and 529 deletions

View File

@ -18,6 +18,8 @@ class CreateImportmapsTable extends Migration {
$table->timestamps();
$table->integer('user_id')->unsigned();
$table->string('file',500);
$table->integer('totaljobs')->unsigned();
$table->integer('jobsdone')->unsigned();
// connect maps to users
$table->foreign('user_id')

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
<?php
use Illuminate\Database\Eloquent\Model as Eloquent;
use LaravelBook\Ardent\Ardent as Ardent;
/**
* Class Importmap
*
@ -14,9 +15,22 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
* @method static \Illuminate\Database\Query\Builder|\Importmap whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Importmap whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\Importmap whereFile($value)
* @property integer $totaljobs
* @property integer $jobsdone
* @method static \Illuminate\Database\Query\Builder|\Importmap whereTotaljobs($value)
* @method static \Illuminate\Database\Query\Builder|\Importmap whereJobsdone($value)
*/
class Importmap extends Eloquent
class Importmap extends Ardent
{
public static $rules
= [
'user_id' => 'required|exists:users,id',
'file' => 'required',
'totaljobs' => 'numeric|required|min:0',
'jobsdone' => 'numeric|required|min:0',
];
/**
* User
*
@ -26,4 +40,13 @@ class Importmap extends Eloquent
{
return $this->belongsTo('User');
}
public function pct()
{
if ($this->jobsdone == 0 || $this->totaljobs == 0) {
return 0;
} else {
return round((($this->jobsdone / $this->totaljobs) * 100), 1);
}
}
}