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,22 +1,36 @@
<?php
use Illuminate\Database\Eloquent\Model as Eloquent;
use LaravelBook\Ardent\Ardent as Ardent;
/**
* Class Importmap
*
* @property-read \User $user
* @property integer $id
* @property-read \User $user
* @property integer $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property integer $user_id
* @property string $file
* @property integer $user_id
* @property string $file
* @method static \Illuminate\Database\Query\Builder|\Importmap whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Importmap whereCreatedAt($value)
* @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);
}
}
}