Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sisage
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marcos Albano
sisage
Commits
20a5e93d
Commit
20a5e93d
authored
Jan 24, 2021
by
Marcos Roberto Silva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validacao do cadastro de usuario
parent
76b62491
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
13 deletions
+64
-13
UserController.php
app/Http/Controllers/Admin/UserController.php
+19
-12
AppServiceProvider.php
app/Providers/AppServiceProvider.php
+3
-0
DocumentoPessoaRepositoryInterface.php
...sitories/Contracts/DocumentoPessoaRepositoryInterface.php
+14
-0
AbstractRepository.php
app/Repositories/Eloquent/AbstractRepository.php
+11
-0
DocumentoPessoaRepository.php
app/Repositories/Eloquent/DocumentoPessoaRepository.php
+13
-0
agendamento.php
resources/lang/en/agendamento.php
+1
-0
agendamento.php
resources/lang/pt-br/agendamento.php
+1
-0
create.blade.php
resources/views/admin/users/create.blade.php
+2
-1
No files found.
app/Http/Controllers/Admin/UserController.php
View file @
20a5e93d
...
...
@@ -3,11 +3,13 @@
namespace
App\Http\Controllers\Admin
;
use
App\Http\Controllers\Controller
;
use
App\Models\DocumentoPessoa
;
use
App\Repositories\Contracts\UserRepositoryInterface
;
use
Illuminate\Http\Request
;
use
Illuminate\Validation\Rule
;
use
Validator
;
use
Illuminate\Support\Facades\Hash
;
use
Illuminate\Support\Facades\Validator
as
FacadesValidator
;
class
UserController
extends
Controller
{
...
...
@@ -27,9 +29,11 @@ class UserController extends Controller
*/
public
function
index
(
Request
$request
)
{
$columnList
=
[
'id'
=>
'#'
,
'nome'
=>
trans
(
'agendamento.name'
),
'email'
=>
trans
(
'agendamento.email'
),
$columnList
=
[
'id'
=>
'#'
,
'nome'
=>
trans
(
'agendamento.name'
),
'email'
=>
trans
(
'agendamento.email'
),
'cpf'
=>
trans
(
'agendamento.cpf'
),
'sobrenome'
=>
trans
(
'agendamento.sobrenome'
),
'telefone'
=>
trans
(
'agendamento.telefone'
),
'data_nascimento'
=>
trans
(
'agendamento.data_nascimento'
)];
'data_nascimento'
=>
trans
(
'agendamento.data_nascimento'
)
];
$page
=
trans
(
'agendamento.user_list'
);
...
...
@@ -48,8 +52,10 @@ class UserController extends Controller
(
object
)
[
'url'
=>
''
,
'title'
=>
trans
(
'agendamento.list'
,
[
'page'
=>
$page
])],
];
return
view
(
'admin.'
.
$routeName
.
'.index'
,
[
'list'
=>
$list
,
'search'
=>
$search
,
'page'
=>
$page
,
'routeName'
=>
$routeName
,
'columnList'
=>
$columnList
,
'breadcrumb'
=>
$breadcrumb
]);
return
view
(
'admin.'
.
$routeName
.
'.index'
,
[
'list'
=>
$list
,
'search'
=>
$search
,
'page'
=>
$page
,
'routeName'
=>
$routeName
,
'columnList'
=>
$columnList
,
'breadcrumb'
=>
$breadcrumb
]);
}
/**
...
...
@@ -71,7 +77,6 @@ class UserController extends Controller
];
return
view
(
'admin.'
.
$routeName
.
'.create'
,
[
'page'
=>
$page
,
'page_create'
=>
$page_create
,
'routeName'
=>
$routeName
,
'breadcrumb'
=>
$breadcrumb
]);
}
/**
...
...
@@ -85,7 +90,7 @@ class UserController extends Controller
$data
=
$request
->
all
();
$data
[
'password'
]
=
Hash
::
make
(
$data
[
'password'
]);
Validator
::
make
(
$data
,
[
Facades
Validator
::
make
(
$data
,
[
'name'
=>
'required|string|max:255'
,
'sobrenome'
=>
'required|string'
,
'email'
=>
'required|string|email|max:255|unique:users'
,
...
...
@@ -95,16 +100,17 @@ class UserController extends Controller
'data_nascimento'
=>
'required'
,
]);
if
(
$this
->
model
->
create
(
$data
))
{
$documentosPessoa
=
DocumentoPessoa
::
where
(
'cpf'
,
$data
[
'cpf'
])
->
first
();
if
(
$documentosPessoa
)
{
$this
->
model
->
create
(
$data
);
session
()
->
flash
(
'msg'
,
trans
(
'agendamento.record_added_successfully'
));
session
()
->
flash
(
'status'
,
'success'
);
// success error notification
return
redirect
()
->
back
();
}
else
{
}
else
if
(
$documentosPessoa
==
null
)
{
session
()
->
flash
(
'msg'
,
trans
(
'agendamento.error_adding_registry'
));
session
()
->
flash
(
'status'
,
'error'
);
// success error notification
return
redirect
()
->
back
();
}
}
/**
...
...
@@ -165,7 +171,6 @@ class UserController extends Controller
return
view
(
'admin.'
.
$routeName
.
'.edit'
,
[
'page'
=>
$page
,
'page2'
=>
$page2
,
'register'
=>
$register
,
'routeName'
=>
$routeName
,
'breadcrumb'
=>
$breadcrumb
]);
}
return
redirect
()
->
route
(
$routeName
.
'.index'
);
}
/**
...
...
@@ -184,7 +189,7 @@ class UserController extends Controller
unset
(
$data
[
'password'
]);
}
Validator
::
make
(
$data
,
[
Facades
Validator
::
make
(
$data
,
[
'name'
=>
'required|string|max:255'
,
'sobrenome'
=>
'required|string'
,
'email'
=>
[
'required'
,
'string'
,
'email'
,
'max:255'
,
Rule
::
unique
(
'users'
)
->
ignore
(
$id
)],
...
...
@@ -194,6 +199,8 @@ class UserController extends Controller
'data_nascimento'
=>
'required'
,
]);
if
(
$this
->
model
->
update
(
$data
,
$id
))
{
session
()
->
flash
(
'msg'
,
trans
(
'agendamento.successfully_edited_record'
));
session
()
->
flash
(
'status'
,
'success'
);
// success error notification
...
...
app/Providers/AppServiceProvider.php
View file @
20a5e93d
...
...
@@ -41,5 +41,8 @@ class AppServiceProvider extends ServiceProvider
$this
->
app
->
bind
(
'App\Repositories\Contracts\AgendamentoRepositoryInterface'
,
'App\Repositories\Eloquent\AgendamentoRepository'
);
$this
->
app
->
bind
(
'App\Repositories\Contracts\DocumentoPessoaRepositoryInterface'
,
'App\Repositories\Eloquent\DocumentoPessoaRepository'
);
}
}
app/Repositories/Contracts/DocumentoPessoaRepositoryInterface.php
0 → 100644
View file @
20a5e93d
<?php
namespace
App\Repositories\Contracts
;
interface
DocumentoPessoaRepositoryInterface
{
public
function
all
(
string
$column
=
'cpf'
);
public
function
paginate
(
int
$paginate
=
10
,
string
$column
=
'id'
,
string
$order
=
'ASC'
);
public
function
findWhereLike
(
array
$columns
,
string
$search
,
string
$column
=
'id'
,
string
$order
=
'ASC'
);
public
function
create
(
array
$data
);
public
function
find
(
int
$id
);
public
function
update
(
array
$data
,
int
$id
);
public
function
delete
(
int
$id
);
}
app/Repositories/Eloquent/AbstractRepository.php
View file @
20a5e93d
...
...
@@ -62,6 +62,17 @@ abstract class AbstractRepository
}
}
public
function
findWhere
(
$column
,
$valor
)
{
return
$this
->
model
->
where
(
$column
,
$valor
)
->
get
();
}
public
function
findWhereFirst
(
$column
,
$valor
)
{
return
$this
->
model
->
where
(
$column
,
$valor
)
->
first
();
}
protected
function
resolveModel
()
{
return
app
(
$this
->
model
);
...
...
app/Repositories/Eloquent/DocumentoPessoaRepository.php
0 → 100644
View file @
20a5e93d
<?php
namespace
App\Repositories\Eloquent
;
use
App\Repositories\Contracts\DocumentoPessoaRepositoryInterface
;
use
App\Models\DocumentoPessoa
;
use
Illuminate\Support\Facades\Hash
;
class
DocumentoPessoaRepository
extends
AbstractRepository
implements
DocumentoPessoaRepositoryInterface
{
protected
$model
=
DocumentoPessoa
::
class
;
}
resources/lang/en/agendamento.php
View file @
20a5e93d
...
...
@@ -54,4 +54,5 @@ return [
'data_nascimento'
=>
'Date of birth'
,
'telefone'
=>
'Phone'
,
'sobrenome'
=>
'Surname'
,
'next'
=>
'Next'
,
];
resources/lang/pt-br/agendamento.php
View file @
20a5e93d
...
...
@@ -52,4 +52,5 @@ return [
'data_nascimento'
=>
'Data de nascimento'
,
'telefone'
=>
'Telefone'
,
'sobrenome'
=>
'Sobrenome'
,
'next'
=>
'Próximo'
,
];
\ No newline at end of file
resources/views/admin/users/create.blade.php
View file @
20a5e93d
...
...
@@ -12,7 +12,8 @@
@
form
([
'action'
=>
route
(
$routeName
.
'.store'
),
'method'
=>
'POST'
])
@
include
(
'admin.'
.
$routeName
.
'.form'
)
<
button
class
=
"btn btn-primary btn-lg"
style
=
"float: right"
>@
lang
(
'agendamento.add'
)
</
button
>
@
csrf
<
button
class
=
"btn btn-primary btn-lg"
style
=
"float: right"
>@
lang
(
'agendamento.next'
)
</
button
>
@
endform
@
endpage
...
...
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