File: /home/imensosw/www/ezwork/app/Models/Evaluation.php
<?php
/**
* EvaluationModel class file
*
* PHP Version 7.2
*
* @category Model
* @package Ez
* @author Imenso Software <admin@imensosoftware.com>
* @license http://imensosoftware/license.php GNU Public License
* @link http://imensosoftware.com/recipes
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use DB;
/**
* EvaluationModel class
*
* The class manage Evaluation related queries
*
* @category EvaluationModel
* @package Ez
* @author Imenso Software <admin@imensosoftware.com>
* @license http://imensosoftware/license.php GNU Public License
* @link http://imensosoftware.com/recipes
*/
class Evaluation extends Model
{
public $table = 'evaluations';
public $fillable = [
'evaluation_name',
'evaluation_description',
'evaluation_text',
'instructions',
'evaluation_text_class',
'from_language_id',
'to_language_id',
'duration',
'semantic_score',
'terminology_score',
'syntax_score',
'quality_score',
'beauty_score',
'status_id',
'evaluation_file',
];
/**
* GetEvaluations gets the list of evaluations and
* return evaluations list.
*
* @param array data
* @return \App\Models\Evaluation
*/
public static function getEvaluations($data)
{
$evaluations = self::select(
'evaluations.*',
'from_languages.language_l as from_language',
'to_languages.language_l as to_language',
DB::raw(
'evaluations.semantic_score+evaluations.terminology_score+evaluations.syntax_score+
evaluations.quality_score+evaluations.beauty_score AS total_score'
)
)->leftJoin(
'languages as from_languages',
'from_languages.id',
'=',
'evaluations.from_language_id'
)->leftJoin(
'languages as to_languages',
'to_languages.id',
'=',
'evaluations.to_language_id'
)->groupBy('evaluations.id')->get();
return $evaluations;
}
// end getEvaluations()
}
// end class