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
pad-upe
Commits
76bc95c5
Commit
76bc95c5
authored
Dec 16, 2022
by
alissonalbuquerque
Browse files
add correção de criação de PAD
parent
cb0ebb12
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/DashboardController.php
View file @
76bc95c5
...
@@ -27,12 +27,10 @@ class DashboardController extends Controller
...
@@ -27,12 +27,10 @@ class DashboardController extends Controller
}
}
if
(
$user
->
isTypeTeacher
())
if
(
$user
->
isTypeTeacher
())
{
{
$userType
=
$user
->
profile
(
UserType
::
TEACHER
);
$userPads
=
$userPads
=
UserPad
::
initQuery
()
UserPad
::
initQuery
()
->
whereUser
(
$user
Type
->
id
)
->
whereUser
(
$user
->
id
)
->
wherePadStatus
(
Status
::
ATIVO
)
->
wherePadStatus
(
Status
::
ATIVO
)
->
get
();
->
get
();
...
...
app/Http/Controllers/PadController.php
View file @
76bc95c5
...
@@ -102,13 +102,13 @@ class PadController extends Controller
...
@@ -102,13 +102,13 @@ class PadController extends Controller
foreach
(
$users
as
$user
)
foreach
(
$users
as
$user
)
{
{
$
userTyp
e
=
$user
->
profile
(
UserType
::
TEACHER
);
$
profil
e
=
$user
->
profile
(
UserType
::
TEACHER
);
if
(
$
userTyp
e
)
if
(
$
profil
e
)
{
{
$userPad
=
new
UserPad
();
$userPad
=
new
UserPad
();
$userPad
->
pad_id
=
$model
->
id
;
$userPad
->
pad_id
=
$model
->
id
;
$userPad
->
user_
type_
id
=
$user
Type
->
id
;
$userPad
->
user_id
=
$user
->
id
;
$userPad
->
status
=
Status
::
ATIVO
;
$userPad
->
status
=
Status
::
ATIVO
;
$userPad
->
save
();
$userPad
->
save
();
...
...
app/Models/UserPad.php
View file @
76bc95c5
...
@@ -16,10 +16,10 @@ class UserPad extends Model
...
@@ -16,10 +16,10 @@ class UserPad extends Model
protected
$table
=
'user_pad'
;
protected
$table
=
'user_pad'
;
protected
$fillable
=
[
'id'
,
'user_
type_
id'
,
'pad_id'
,
'status'
];
protected
$fillable
=
[
'id'
,
'user_id'
,
'pad_id'
,
'status'
];
public
function
user
()
{
public
function
user
()
{
return
$this
->
belongsTo
(
User
Type
::
class
);
return
$this
->
belongsTo
(
User
::
class
);
}
}
public
function
pad
()
{
public
function
pad
()
{
...
...
app/Queries/UserPadQuery.php
View file @
76bc95c5
...
@@ -29,7 +29,7 @@ class UserPadQuery extends CustomQuery
...
@@ -29,7 +29,7 @@ class UserPadQuery extends CustomQuery
*/
*/
public
function
whereUser
(
$user_type_id
,
$operator
=
'='
)
public
function
whereUser
(
$user_type_id
,
$operator
=
'='
)
{
{
$this
->
query
=
$this
->
query
->
where
(
'user_
type_
id'
,
$operator
,
$user_type_id
);
$this
->
query
=
$this
->
query
->
where
(
'user_id'
,
$operator
,
$user_type_id
);
return
self
::
$instance
;
return
self
::
$instance
;
}
}
...
...
database/migrations/2022_12_16_113626_alter_user_pad_table.php
0 → 100644
View file @
76bc95c5
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
AlterUserPadTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'user_pad'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'user_type_id'
);
$table
->
foreignId
(
'user_id'
)
->
after
(
'id'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'user_pad'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'user_id'
);
$table
->
foreignId
(
'user_type_id'
)
->
after
(
'id'
);
});
}
}
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