1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace App\Repositories\Models\Exam;
- use App\Repositories\Models\Base\Admin;
- use App\Repositories\Models\Model;
- use Prettus\Repository\Contracts\Transformable;
- use Prettus\Repository\Traits\TransformableTrait;
- /**
- * Class PaperResult.
- *
- * @package namespace App\Repositories\Models\Exam;
- */
- class PaperResult extends Model implements Transformable
- {
- use TransformableTrait;
- protected $table = 'exam_paper_results';
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $guarded = [];
- protected $casts = [
- 'result' => 'array',
- 'imgs' => 'array'
- ];
- public function paper()
- {
- return $this->belongsTo(Paper::class)->select(['id', 'name', 'submit_nums', 'topic_nums', 'mark']);
- }
- public function assign_admin()
- {
- return $this->belongsTo(Admin::class)->select(['id', 'username', 'name']);
- }
- public function polling_admin()
- {
- return $this->belongsTo(Admin::class)->select(['id', 'username', 'name']);
- }
- public function getImgUrlsAttribute()
- {
- $imgs = $this->fromJson($this->attributes['imgs']);
- $urls = [];
- if (is_array($imgs)) {
- foreach ($imgs as $img) {
- $urls[] = path_to_url($img);
- }
- }
- return $urls;
- }
- }
|