Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Walter Felipe
submeta
Commits
ba7c0206
Commit
ba7c0206
authored
Aug 31, 2021
by
José Rômulo
Browse files
Adiciona model Substituicao e seus relacionamentos
parent
131d87b4
Changes
6
Show whitespace changes
Inline
Side-by-side
app/Arquivo.php
View file @
ba7c0206
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
App
;
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
class
Arquivo
extends
Model
class
Arquivo
extends
Model
{
{
...
@@ -11,6 +12,8 @@ class Arquivo extends Model
...
@@ -11,6 +12,8 @@ class Arquivo extends Model
*
*
* @var array
* @var array
*/
*/
use
SoftDeletes
;
protected
$fillable
=
[
protected
$fillable
=
[
'nome'
,
'titulo'
,
'versao'
,
'versaoFinal'
,
'data'
,
'trabalhoId'
,
'participanteId'
'nome'
,
'titulo'
,
'versao'
,
'versaoFinal'
,
'data'
,
'trabalhoId'
,
'participanteId'
];
];
...
@@ -19,6 +22,10 @@ class Arquivo extends Model
...
@@ -19,6 +22,10 @@ class Arquivo extends Model
return
$this
->
belongsTo
(
'App\Trabalho'
,
'trabalhoId'
);
return
$this
->
belongsTo
(
'App\Trabalho'
,
'trabalhoId'
);
}
}
public
function
substituicaos
(){
return
$this
->
hasMany
(
'App\Substituicao'
);
}
public
function
participante
()
{
public
function
participante
()
{
return
$this
->
belongsTo
(
'App\Participante'
,
'participanteId'
);
return
$this
->
belongsTo
(
'App\Participante'
,
'participanteId'
);
}
}
...
...
app/Participante.php
View file @
ba7c0206
...
@@ -15,6 +15,15 @@ class Participante extends Model
...
@@ -15,6 +15,15 @@ class Participante extends Model
public
function
user
(){
public
function
user
(){
return
$this
->
belongsTo
(
'App\User'
);
return
$this
->
belongsTo
(
'App\User'
);
}
}
public
function
participanteSubstituido
(){
return
$this
->
hasMany
(
'App\Substituicao'
);
}
public
function
participanteSubstituto
(){
return
$this
->
hasMany
(
'App\Substituicao'
);
}
public
function
trabalhos
(){
public
function
trabalhos
(){
return
$this
->
belongsToMany
(
'App\Trabalho'
,
'trabalho_participante'
);
return
$this
->
belongsToMany
(
'App\Trabalho'
,
'trabalho_participante'
);
}
}
...
...
app/Substituicao.php
0 → 100644
View file @
ba7c0206
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
class
Substituicao
extends
Model
{
//
protected
$fillable
=
[
'status'
,
'tipo'
,
'justificativa'
,
'causa'
,
'participanteSubstituido_id'
,
'participanteSubstituto_id'
];
public
function
participanteSubstituido
(){
return
$this
->
belongsTo
(
'App\Participante'
,
'participanteSubstituido_id'
);
}
public
function
participanteSubstituto
(){
return
$this
->
belongsTo
(
'App\Participante'
,
'participanteSubstituto_id'
);
}
public
function
planoSubstituto
(){
return
$this
->
belongsTo
(
'App\Arquivo'
,
'planoSubstituto_id'
);
}
public
function
trabalho
(){
return
$this
->
belongsTo
(
'App\Trabalho'
);
}
}
app/Trabalho.php
View file @
ba7c0206
...
@@ -97,4 +97,8 @@ class Trabalho extends Model
...
@@ -97,4 +97,8 @@ class Trabalho extends Model
public
function
avaliadors
(){
public
function
avaliadors
(){
return
$this
->
belongsToMany
(
'App\Avaliador'
)
->
withPivot
(
'status'
,
'AnexoParecer'
,
'parecer'
,
'recomendacao'
,
'created_at'
);
return
$this
->
belongsToMany
(
'App\Avaliador'
)
->
withPivot
(
'status'
,
'AnexoParecer'
,
'parecer'
,
'recomendacao'
,
'created_at'
);
}
}
public
function
substituicaos
(){
return
$this
->
hasMany
(
'App\Substituicao'
);
}
}
}
database/migrations/2021_08_27_145845_create_substituicaos_table.php
0 → 100644
View file @
ba7c0206
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateSubstituicaosTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'substituicaos'
,
function
(
Blueprint
$table
)
{
$table
->
bigIncrements
(
'id'
);
$table
->
enum
(
'status'
,
[
'Finalizada'
,
'Negada'
,
'Em Aguardo'
]);
$table
->
enum
(
'tipo'
,
[
'Completa'
,
'TrocarPlano'
,
'ManterPlano'
]);
$table
->
text
(
'justificativa'
)
->
nullable
();
$table
->
string
(
'causa'
)
->
nullable
();
$table
->
unsignedBigInteger
(
'trabalho_id'
);
$table
->
unsignedBigInteger
(
'participanteSubstituido_id'
);
$table
->
unsignedBigInteger
(
'participanteSubstituto_id'
);
$table
->
unsignedBigInteger
(
'planoSubstituto_id'
);
$table
->
dateTime
(
'concluida_em'
)
->
nullable
();
$table
->
foreign
(
'trabalho_id'
)
->
references
(
'id'
)
->
on
(
'trabalhos'
);
$table
->
foreign
(
'participanteSubstituido_id'
)
->
references
(
'id'
)
->
on
(
'participantes'
);
$table
->
foreign
(
'participanteSubstituto_id'
)
->
references
(
'id'
)
->
on
(
'participantes'
);
$table
->
foreign
(
'planoSubstituto_id'
)
->
references
(
'id'
)
->
on
(
'arquivos'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'substituicaos'
);
}
}
database/migrations/2021_08_27_150028_add_softdelete_arquivos.php
0 → 100644
View file @
ba7c0206
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
AddSoftdeleteArquivos
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'arquivos'
,
function
(
Blueprint
$table
)
{
$table
->
softDeletes
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'arquivos'
,
function
(
Blueprint
$table
)
{
$table
->
dropSoftDeletes
();
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment