Resolvido merge

parents 2630f1a2 c9c032bc
......@@ -17,10 +17,9 @@ class RoleController extends Controller
private $model;
private $modelPermission;
public function __construct(RoleRepositoryInterface $model, PermissionRepositoryInterface $modelPermission)
public function __construct(RoleRepositoryInterface $model)
{
$this->model = $model;
$this->modelPermission = $modelPermission;
}
/**
* Display a listing of the resource.
......@@ -65,7 +64,7 @@ class RoleController extends Controller
$page = trans('agendamento.role_list');
$page_create = trans('agendamento.role');
$permissions = $this->modelPermission->all('name');
//$permissions = $this->modelPermission->all('name', 'ASC');
$breadcrumb = [
(object) ['url' => route('home'), 'title' => trans('agendamento.home')],
......@@ -74,7 +73,7 @@ class RoleController extends Controller
];
return view('admin.' . $routeName . '.create', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName,
'breadcrumb' => $breadcrumb, 'permissions' => $permissions]);
'breadcrumb' => $breadcrumb]);
}
......@@ -91,7 +90,7 @@ class RoleController extends Controller
Validator::make($data, [
'name' => 'required|string|max:255',
'description' => 'required|string|max:300',
])->validate();
]);
if ($this->model->create($data)) {
session()->flash('msg', trans('agendamento.record_added_successfully'));
......@@ -181,7 +180,7 @@ class RoleController extends Controller
Validator::make($data, [
'name' => 'required|string|max:255',
'description' => 'required|string|max:300',
])->validate();
]);
if ($this->model->update($data, $id)) {
session()->flash('msg', trans('agendamento.successfully_edited_record'));
......
......@@ -7,8 +7,6 @@ use App\Repositories\Contracts\UserRepositoryInterface;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Validator;
use Illuminate\Support\Facades\Hash;
class UserController extends Controller
{
......@@ -63,6 +61,7 @@ class UserController extends Controller
$routeName = $this->route;
$page = trans('agendamento.user_list');
$page_create = trans('agendamento.user');
//$roles = $this->modelRole->all('name','ASC');
$breadcrumb = [
(object) ['url' => route('home'), 'title' => trans('agendamento.home')],
......@@ -83,7 +82,7 @@ class UserController extends Controller
public function store(Request $request)
{
$data = $request->all();
$data['password'] = Hash::make($data['password']);
//$data['password'] = Hash::make($data['password']);
Validator::make($data, [
'name' => 'required|string|max:255',
......@@ -125,15 +124,15 @@ class UserController extends Controller
(object) ['url' => '', 'title' => trans('agendamento.show_crud', ['page' => $page2])],
];
$delete = false;
if($request->delete ?? false){
if ($request->delete ?? false) {
session()->flash('msg', trans('agendamento.delete_this_record'));
session()->flash('status', 'notification'); // success error notification
$delete = true;
}
return view('admin.' . $routeName . '.show', ['page' => $page, 'delete' => $delete, 'page2' => $page2,'register' => $register, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
return view('admin.' . $routeName . '.show', ['page' => $page, 'delete' => $delete, 'page2' => $page2, 'register' => $register, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
}
return redirect()->route($routeName.'.index');
return redirect()->route($routeName . '.index');
}
/**
......@@ -160,7 +159,7 @@ class UserController extends Controller
return view('admin.' . $routeName . '.edit', ['page' => $page, 'page2' => $page2, 'register' => $register, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
}
return redirect()->route($routeName.'.index');
return redirect()->route($routeName . '.index');
}
......@@ -174,15 +173,15 @@ class UserController extends Controller
public function update(Request $request, $id)
{
$data = $request->all();
$data['password'] = Hash::make($data['password']);
//$data['password'] = Hash::make($data['password']);
if(!$data['password']){
if (!$data['password']) {
unset($data['password']);
}
Validator::make($data, [
'name' => 'required|string|max:255',
'email' => ['required','string','email','max:255',Rule::unique('users')->ignore($id)],
'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users')->ignore($id)],
'password' => 'sometimes|required|string|min:6|confirmed',
]);
......@@ -205,15 +204,15 @@ class UserController extends Controller
*/
public function destroy($id)
{
if($this->model->delete($id)){
if ($this->model->delete($id)) {
session()->flash('msg', trans('agendamento.registration_deleted_successfully'));
session()->flash('status', 'error'); // success error notification
}else{
} else {
session()->flash('msg', trans('agendamento.error_deleting_record'));
session()->flash('status', 'error'); // success error notification
}
$routeName = $this->route;
return redirect()->route($routeName.'.index');
return redirect()->route($routeName . '.index');
}
}
......@@ -14,6 +14,6 @@ class Permission extends Model
// public function roles()
// {
// return $this->belongsToMany(Role::class);
// return $this->belongsToMany(Role::class, 'id', 'id');
// }
}
......@@ -2,6 +2,8 @@
namespace App\Repositories\Contracts;
use PhpParser\Node\Expr\Cast\Bool_;
interface RoleRepositoryInterface
{
public function all(string $column = 'id', string $order = 'ASC');
......
......@@ -32,7 +32,7 @@ abstract class AbstractRepository
return $query->orderBy($column, $order)->get();
}
public function create(array $data):Bool
public function create(array $data)
{
return (bool) $this->model->create($data);
}
......
......@@ -8,4 +8,43 @@ use App\Repositories\Contracts\RoleRepositoryInterface;
class RoleRepository extends AbstractRepository implements RoleRepositoryInterface
{
protected $model = Role::class;
// public function __construct()
// {
// $this->model = $this->resolveModel();
// }
// public function create(array $data):Bool
// {
// $register = $this->model->create($data);
// if(isset($data['permissions']) && count($data['permissions'])){
// foreach ($data['permissions'] as $key => $value) {
// $register->permissions()->attach($value);
// }
// }
// return (bool) $register;
// }
// public function update(array $data, int $id):Bool
// {
// $register = $this->find($id);
// if($register){
// $permissions = $register->permissions;
// if(count($permissions)){
// foreach ($permissions as $key => $value) {
// $register->permissions()->detach($value->id);
// }
// }
// if(isset($data['permissions']) && count($data['permissions'])){
// foreach ($data['permissions'] as $key => $value) {
// $register->permissions()->attach($value);
// }
// }
// return (bool) $register->update($data);
// }else{
// return false;
// }
// }
}
......@@ -4,9 +4,33 @@ namespace App\Repositories\Eloquent;
use App\Repositories\Contracts\UserRepositoryInterface;
use App\User;
use Illuminate\Support\Facades\Hash;
class UserRepository extends AbstractRepository implements UserRepositoryInterface
{
protected $model = User::class;
// public function __construct()
// {
// $this->model = $this->resolveModel();
// }
// public function create(array $data):Bool
// {
// $data['password'] = Hash::make($data['password']);
// return (bool) $this->model->create($data);
// }
// public function update(array $data, int $id):Bool
// {
// $register = $this->find($id);
// if($register){
// if($data['password'] ?? false){
// $data['password'] = Hash::make($data['password']);
// }
// return (bool) $register->update($data);
// }else{
// return false;
// }
// }
}
......@@ -12,13 +12,14 @@ class Role extends Model
'name', 'description',
];
public function users()
{
return $this->belongsToMany(User::class, 'id');
}
//id: na tabela users, id: na tabela roles
// public function users()
// {
// return $this->belongsToMany(User::class, 'id', 'id');
// }
public function permissions()
{
return $this->belongsToMany(Permission::class, 'id');
}
// public function permissions()
// {
// return $this->belongsToMany(Permission::class, 'id', 'id');
// }
}
......@@ -27,10 +27,10 @@ class User extends Authenticatable
protected $hidden = [
'password', 'remember_token',
];
public function roles()
{
return $this->belongsToMany(Role::class, 'id');
}
//id: na tabela users, id: na tabela roles
// public function roles()
// {
// return $this->belongsToMany(Role::class, 'id', 'id');
// }
}
......@@ -7,7 +7,6 @@
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
</div>
<div class="form-group col-6">
<label for="email">{{ __('agendamento.email') }}</label>
......
......@@ -5,19 +5,23 @@
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<!-- <div class="card-header">{{ __('Login') }}</div> --> <!--Remover esta linha -->
<div class="imaLogos">
<img src="http://localhost:81/sisage/public/img/logo_governo.png">
<img src="{!! asset('img/Logo governo_150.png') !!}">
</div>
{{-- <div class="card-header">{{ __('Login') }}</div> --}}
<div class="card-body">
<form method="POST" action="{{ route('login') }}" aria-label="{{ __('agendamento.login') }}">
@csrf
<div class="form-group row">
<label for="email" class="col-sm-4 col-form-label text-md-right"></label>
<div class="col-md-6">
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus placeholder="{{ __('agendamento.email') }}">
......@@ -28,7 +32,6 @@
@endif
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right"></label>
......@@ -61,6 +64,8 @@
{{ __('agendamento.login') }}
</button>
<a class="btn btn-btn btn-primary" href="{{ route('users.create') }}">Cadastro</a>
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('agendamento.forgot_your_password') }}
</a>
......
......@@ -27,7 +27,7 @@
<nav class="navbar navbar-expand-md navbar-light navbar-laravel">
<div class="container">
<img src="{!! asset('img/logoidace.png') !!}">
<b><a class="navbar-brand" href="{{ url('/') }}">
<b><a class="navbar-brand" href="{{ url('/home') }}">
SISAGE
</a></b>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
......@@ -59,6 +59,9 @@
{{ Auth::user()->name }} <span class="caret"></span>
</a>
{{-- <div class="imaLogos">
<img id="govce" src="imagem/Logo governo_150px.png" alt="">
</div> --}}
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
......
......@@ -38,8 +38,9 @@ Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::prefix('admin')->middleware('auth')->namespace('Admin')->group(function () {
Route::prefix('admin')->namespace('Admin')->group(function () {
Route::resource('/users', 'UserController');
Route::resource('/permissions', 'PermissionController');
Route::resource('/roles', 'RoleController');
});
//->middleware('auth')
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