<?php namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; class Log extends Model { protected $table = 'logs'; protected $guarded = ['id']; public static function getJobProgression(Wowa $wowa) { $logs = self::where('job_id', '=', $wowa->id)->orderBy('generation', 'desc')->first(); $generation = $logs->generation + 1; $generation_number = $wowa->generation_number; return ($generation / $generation_number) * 100; } }