-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from gabriel-schenato/dev
Dev
- Loading branch information
Showing
88 changed files
with
6,220 additions
and
586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Emaj\Entities\Cadastro; | ||
|
||
use Emaj\Entities\Movimento\FichaTriagem; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Classe da entidade Avaliação | ||
* | ||
* PHP version 7.2 | ||
* | ||
* @category Entity | ||
* @package Cadastro | ||
* @author Gabriel Schenato <gabriel@uniplaclages.edu.br> | ||
* @license http://www.opensource.org/licenses/mit-license.html MIT License | ||
* @link https://www.uniplaclages.edu.br/ | ||
* @since 1.1.0 | ||
*/ | ||
class Avaliacao extends Model | ||
{ | ||
|
||
/** | ||
* The database table used by the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'avaliacoes'; | ||
protected $fillable = [ | ||
'aluno_id', | ||
'ficha_triagem_id', | ||
'avaliador_id', | ||
'data', | ||
'observacoes' | ||
]; | ||
|
||
/** | ||
* Pega o aluno associado a essa avaliação. | ||
*/ | ||
public function aluno() | ||
{ | ||
return $this->belongsTo(Aluno::class, 'aluno_id'); | ||
} | ||
|
||
/** | ||
* Pega a ficha de triagem associada a essa avaliação. | ||
*/ | ||
public function ficha_triagem() | ||
{ | ||
return $this->belongsTo(FichaTriagem::class, 'ficha_triagem_id'); | ||
} | ||
|
||
/** | ||
* Pega o avaliador associado a essa avaliação. | ||
*/ | ||
public function avaliador() | ||
{ | ||
return $this->belongsTo(Usuario::class, 'avaliador_id'); | ||
} | ||
|
||
/** | ||
* Pega todos os arquivos anexados a essa avaliação. | ||
*/ | ||
public function avaliacao_arquivos() | ||
{ | ||
return $this->hasMany(AvaliacaoArquivo::class, 'avaliacao_id'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace Emaj\Entities\Cadastro; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Classe da entidade Avaliação Arquivo | ||
* | ||
* PHP version 7.2 | ||
* | ||
* @category Entity | ||
* @package Cadastro | ||
* @author Gabriel Schenato <gabriel@uniplaclages.edu.br> | ||
* @license http://www.opensource.org/licenses/mit-license.html MIT License | ||
* @link https://www.uniplaclages.edu.br/ | ||
* @since 1.1.0 | ||
*/ | ||
class AvaliacaoArquivo extends Model | ||
{ | ||
|
||
/** | ||
* The database table used by the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'avaliacao_arquivos'; | ||
protected $appends = ['nome_arquivo_extensao', 'tamanho_arquivo']; | ||
protected $fillable = [ | ||
'nome', | ||
'arquivo', | ||
'mimetype', | ||
'extensao', | ||
'tamanho', | ||
'avaliacao_id' | ||
]; | ||
|
||
/** | ||
* Pega a avaliação associado a esse arquivo. | ||
*/ | ||
public function avaliacao() | ||
{ | ||
return $this->belongsTo(Avaliacao::class, 'avaliacao_id'); | ||
} | ||
|
||
protected function getNomeArquivoExtensaoAttribute() | ||
{ | ||
return $this->attributes['nome'] . '.' . $this->attributes['extensao']; | ||
} | ||
|
||
protected function getTamanhoArquivoAttribute() | ||
{ | ||
return $this->formatBytes($this->attributes['tamanho']); | ||
} | ||
|
||
/** | ||
* Format bytes to kb, mb, gb, tb | ||
* | ||
* @param integer $size | ||
* @param integer $precision | ||
* @return integer | ||
*/ | ||
private function formatBytes($size, $precision = 2) | ||
{ | ||
if ($size > 0) { | ||
$size = (int) $size; | ||
$base = log($size) / log(1024); | ||
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB'); | ||
|
||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; | ||
} | ||
return $size; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.