Unverified Commit 97fb114d authored by GuilhermeGz's avatar GuilhermeGz Committed by GitHub
Browse files

Merge pull request #541 from antonioDurval/master

Verificação do anexo do plano de trabalho na edição de projetos
parents 974081c6 2edd10f2
......@@ -2,8 +2,11 @@
namespace App\Http\Requests;
use App\Arquivo;
use App\Evento;
use App\Participante;
use App\Trabalho;
use App\User;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Http\FormRequest;
......@@ -33,6 +36,14 @@ class UpdateTrabalho extends FormRequest
if($this->has('marcado')){
foreach ($this->get('marcado') as $key => $value) {
if( intval($value) == $key){
$usuario = User::where('email', $this->email[$value])->first();
// if(isset($usuario)){
// $participante = Participante::where('user_id', $usuario->id)->where('trabalho_id', $projeto->id)->first();
// $arquivo = Arquivo::where('trabalhoId', $projeto->id)->where('participanteId', $participante->id)->first();
// }
//user
$rules['name.'.$value] = ['required', 'string'];
$rules['email.'.$value] = ['required', 'string'];
......@@ -58,8 +69,14 @@ class UpdateTrabalho extends FormRequest
$rules['media_do_curso.' . $value] = ['required', 'string'];
}
$rules['nomePlanoTrabalho.'.$value] = ['required', 'string'];
$rules['anexoPlanoTrabalho.'.$value] = ['required', 'mimes:pdf'];
if(isset($usuario)){
$participante = Participante::where('user_id', $usuario->id)->where('trabalho_id', $projeto->id)->first();
$arquivo = Arquivo::where('trabalhoId', $projeto->id)->where('participanteId', $participante->id)->first();
$rules['anexoPlanoTrabalho.'.$value] = [Rule::requiredIf($arquivo == null), 'mimes:pdf'];
}else {
$rules['anexoPlanoTrabalho.'.$value] = ['required', 'mimes:pdf'];
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment