'required|exists:users,id', 'file' => 'required', 'totaljobs' => 'numeric|required|min:0', 'jobsdone' => 'numeric|required|min:0', ]; /** * User * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function user() { 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); } } }