update code

This commit is contained in:
manhlab
2021-04-07 06:32:42 -04:00
parent 7fb98911a6
commit a4753625f6
779 changed files with 335717 additions and 0 deletions

View File

@@ -0,0 +1,119 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\AttachmentRepository;
use App\Http\Requests\Attachment\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
};
use App\Traits\Attachmentable;
/**
* Class AttachmentsController.
*
* @package namespace App\Http\Controllers\Api;
*/
class AttachmentsController extends Controller
{
use Attachmentable;
/**
* @var AttachmentRepository
*/
protected $repository;
/**
* AttachmentsController constructor.
*
* @param AttachmentRepository $repository
*/
public function __construct(AttachmentRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->all();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$data = $this->attachment($request->file('attachments'), $request->document_id);
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->respond($data);
}
/**
* Download attachment
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function download(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->downloadAttachment($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
$data = $this->repository->update($request->all(), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->removeAttachment($this->repository->find($id));
$this->repository->delete($id);
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\BookRepository;
use App\Http\Requests\Book\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
};
/**
* Class BooksController.
*
* @package namespace App\Http\Controllers\Api;
*/
class BooksController extends Controller
{
/**
* @var BookRepository
*/
protected $repository;
/**
* BooksController constructor.
*
* @param BookRepository $repository
*/
public function __construct(BookRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->all();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$data = $this->repository->create($request->all());
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
$data = $this->repository->update($request->all(), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->repository->delete($id);
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\DepartmentRepository;
use App\Http\Requests\Department\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
};
/**
* Class DepartmentsController.
*
* @package namespace App\Http\Controllers\Api;
*/
class DepartmentsController extends Controller
{
/**
* @var DepartmentRepository
*/
protected $repository;
/**
* DepartmentsController constructor.
*
* @param DepartmentRepository $repository
*/
public function __construct(DepartmentRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->all();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$data = $this->repository->create($request->all());
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
$data = $this->repository->update($request->all(), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->repository->delete($id);
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\DocumentTypeRepository;
use App\Http\Requests\DocumentType\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
};
/**
* Class DocumentTypesController.
*
* @package namespace App\Http\Controllers\Api;
*/
class DocumentTypesController extends Controller
{
/**
* @var DocumentTypeRepository
*/
protected $repository;
/**
* DocumentTypesController constructor.
*
* @param DocumentTypeRepository $repository
*/
public function __construct(DocumentTypeRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->all();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$data = $this->repository->create($request->all());
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
$data = $this->repository->update($request->all(), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->repository->delete($id);
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,110 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\DocumentRepository;
use App\Http\Requests\Document\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
};
use App\Traits\Attachmentable;
use App\Events\UserViewedDocument;
/**
* Class DocumentsController.
*
* @package namespace App\Http\Controllers\Api;
*/
class DocumentsController extends Controller
{
use Attachmentable;
/**
* @var DocumentRepository
*/
protected $repository;
/**
* DocumentsController constructor.
*
* @param DocumentRepository $repository
*/
public function __construct(DocumentRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->paginate();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$data = $this->repository->create($request->all());
if($request->filled('attachments')){
$this->attachments($request->file('attachments'), $data->id);
}
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
event(new UserViewedDocument($data));
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
$data = $this->gateAction($this->repository, $request, $id) ?: $this->repository->update($request->except('creator_id'), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->repository->delete($id);
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\UserRepository;
use App\Http\Requests\Me\{
ShowRequest,
UpdateRequest,
};
/**
* Class MeController.
*
* @package namespace App\Http\Controllers\Api;
*/
class MeController extends Controller
{
/**
* @var UserRepository
*/
protected $repository;
/**
* MeController constructor.
*
* @param UserRepository $repository
*/
public function __construct(UserRepository $repository)
{
$this->repository = $repository;
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request)
{
$data = $this->repository->find($request->user()->id);
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
*
* @return Response
*/
public function update(UpdateRequest $request)
{
if($request->filled('password')){
$request->password = \Hash::make($request->password);
}
$data = $this->repository->update(
$request->except(['department_id', 'title_id', 'active', 'id']),
$request->user()->id
);
return $this->respond($data);
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class NotificationsController extends Controller
{
/**
* Get all notifications
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$data = request()->user()->notifications;
return $this->respond($data);
}
/**
* Get read notifications
*
* @return \Illuminate\Http\Response
*/
public function read()
{
$data = request()->user()->readNotifications;
return $this->respond($data);
}
/**
* Get unread notifications
*
* @return \Illuminate\Http\Response
*/
public function unread()
{
$data = request()->user()->unreadNotifications;
return $this->respond($data);
}
/**
* Mark all as read
*
* @return \Illuminate\Http\Response
*/
public function markAllAsRead()
{
request()->user()->unreadNotifications->markAsRead();
return $this->respondNoContent();
}
/**
* Mark as read
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function markAsRead($id)
{
$data = request()->user()->notifications->where('id', $id)->first();
$data->markAsRead();
return $this->respond($data);
}
/**
* Mark as unread
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function markAsUnread($id)
{
$data = request()->user()->notifications->where('id', $id)->first();
$data->markAsUnread();
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
request()->user()->notifications->where('id', $id)->first()->delete();
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\OrganizeRepository;
use App\Http\Requests\Organize\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
};
/**
* Class OrganizesController.
*
* @package namespace App\Http\Controllers\Api;
*/
class OrganizesController extends Controller
{
/**
* @var OrganizeRepository
*/
protected $repository;
/**
* OrganizesController constructor.
*
* @param OrganizeRepository $repository
*/
public function __construct(OrganizeRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->all();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$data = $this->repository->create($request->all());
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
$data = $this->repository->update($request->all(), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->repository->delete($id);
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\PermissionRepository;
use App\Http\Requests\Permission\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
};
/**
* Class PermissionsController.
*
* @package namespace App\Http\Controllers\Api;
*/
class PermissionsController extends Controller
{
/**
* @var PermissionRepository
*/
protected $repository;
/**
* PermissionsController constructor.
*
* @param PermissionRepository $repository
*/
public function __construct(PermissionRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->all();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$data = $this->repository->create($request->all());
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
$data = $this->repository->update($request->all(), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->repository->delete($id);
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,86 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\DocumentRepository;
use App\Contracts\Repositories\BookRepository;
use App\Http\Requests\Document\{
ExportRequest,
};
/**
* Class ReportsController.
*
* @package namespace App\Http\Controllers\Api;
*/
class ReportsController extends Controller
{
/**
* @var DocumentRepository
*/
protected $repository;
/**
* @var BookRepository
*/
protected $bookRepository;
/**
* ReportsController constructor.
*
* @param DocumentRepository $repository
*/
public function __construct(DocumentRepository $repository, BookRepository $bookRepository)
{
$this->repository = $repository;
$this->bookRepository = $bookRepository;
}
/**
* Download report
*
* @return \Illuminate\Http\Response
*/
public function export(ExportRequest $request)
{
$books = $this->bookRepository->all();
if($request->filled('book')){
$books = collect();
$books->push($this->bookRepository->find($request->book));
}
$books->map(function ($book) use ($request)
{
$documents = $this->repository->scopeQuery(function($query) use ($request, $book)
{
$query->where('book_id', $book->id);
if($request->filled('type')){
$query->where('type_id', $request->type);
}
if($request->filled('from')){
$request->to = $request->to ?: date('Y-m-d');
$query->whereBetween('effective_at', [$request->from, $request->to]);
}
$query
->with(['receivers', 'publisher', 'organizes'])
->orderBy('effective_at')
->orderBy('publisher_id');
return $query;
})->all();
return $book->documents = $documents;
});
$name = auth()->user()->name . ' ' . date('d-m-Y');
$fileName = $name . '.' . strtolower($request->export);
$exporter = new \App\Exports\BooksExport($books, $request->from, $request->to);
return \Excel::download($exporter, $fileName, $request->export);
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\RoleRepository;
use App\Http\Requests\Role\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
GivePermissionRequest,
RevokePermissionRequest,
};
/**
* Class RolesController.
*
* @package namespace App\Http\Controllers\Api;
*/
class RolesController extends Controller
{
/**
* @var RoleRepository
*/
protected $repository;
/**
* RolesController constructor.
*
* @param RoleRepository $repository
*/
public function __construct(RoleRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->all();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$data = $this->repository->create($request->all());
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
$data = $this->repository->update($request->all(), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->repository->delete($id);
return $this->respondNoContent();
}
public function givePermission(GivePermissionRequest $request, $role, $permission){
$this->repository->find($role)->givePermissionTo($permission);
return $this->respondNoContent();
}
public function revokePermission(RevokePermissionRequest $request, $role, $permission){
$this->repository->find($role)->revokePermissionTo($permission);
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\SignerRepository;
use App\Http\Requests\Signer\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
};
/**
* Class SignersController.
*
* @package namespace App\Http\Controllers\Api;
*/
class SignersController extends Controller
{
/**
* @var SignerRepository
*/
protected $repository;
/**
* SignersController constructor.
*
* @param SignerRepository $repository
*/
public function __construct(SignerRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->all();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$data = $this->repository->create($request->all());
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
$data = $this->repository->update($request->all(), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->repository->delete($id);
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\TitleRepository;
use App\Http\Requests\Title\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
};
/**
* Class TitlesController.
*
* @package namespace App\Http\Controllers\Api;
*/
class TitlesController extends Controller
{
/**
* @var TitleRepository
*/
protected $repository;
/**
* TitlesController constructor.
*
* @param TitleRepository $repository
*/
public function __construct(TitleRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->all();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$data = $this->repository->create($request->all());
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
$data = $this->repository->update($request->all(), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->repository->delete($id);
return $this->respondNoContent();
}
}

View File

@@ -0,0 +1,145 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Contracts\Repositories\UserRepository;
use App\Http\Requests\User\{
IndexRequest,
CreateRequest,
ShowRequest,
UpdateRequest,
DestroyRequest,
GiveRoleRequest,
GivePermissionRequest,
ExportRequest,
ImportRequest,
};
/**
* Class UsersController.
*
* @package namespace App\Http\Controllers\Api;
*/
class UsersController extends Controller
{
/**
* @var UserRepository
*/
protected $repository;
/**
* UsersController constructor.
*
* @param UserRepository $repository
*/
public function __construct(UserRepository $repository)
{
$this->repository = $repository;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(IndexRequest $request)
{
$data = $this->repository->paginate();
return $this->respond($data);
}
/**
* Store a newly created resource in storage.
*
* @param $CLASS\CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateRequest $request)
{
$request->merge(['password' => \Hash::make($request->password)]);
$data = $this->repository->create($request->all());
return $this->respondCreated($data);
}
/**
* Display the specified resource.
* @param $CLASS\ShowRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show(ShowRequest $request, $id)
{
$data = $this->repository->find($id);
return $this->respond($data);
}
/**
* Update the specified resource in storage.
*
* @param $CLASS\UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(UpdateRequest $request, $id)
{
if($request->filled('password')){
$request->password = \Hash::make($request->password);
}
$data = $this->repository->update($request->all(), $id);
return $this->respond($data);
}
/**
* Remove the specified resource from storage.
*
* @param $CLASS\DestroyRequest $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy(DestroyRequest $request, $id)
{
$this->repository->delete($id);
return $this->respondNoContent();
}
public function giveRole(GiveRoleRequest $request, $user, $role){
$this->repository->find($user)->assignRole($role);
return $this->respondNoContent();
}
public function revokeRole(GiveRoleRequest $request, $user, $role){
$this->repository->find($user)->removeRole($role);
return $this->respondNoContent();
}
public function givePermission(GiveRoleRequest $request, $user, $permission){
$this->repository->find($user)->givePermissionTo($permission);
return $this->respondNoContent();
}
public function revokePermission(GiveRoleRequest $request, $user, $permission){
$this->repository->find($user)->revokePermissionTo($permission);
return $this->respondNoContent();
}
public function import(ImportRequest $request)
{
\Excel::import(new \App\Imports\UsersImport, $request->file('data'));
return $this->respondNoContent();
}
public function export(ExportRequest $request)
{
$users = $this->repository->all();
$exporter = new \App\Exports\UsersExport($users);
$fileName = 'Danh sách người dùng.' . $request->export;
return \Excel::download($exporter, $fileName, $request->export);
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ConfirmsPasswords;
class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/
use ConfirmsPasswords;
/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
}

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Auth;
use \Illuminate\Http\Request;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
protected function guard()
{
return Auth::guard('web');
}
/**
* Get the needed authorization credentials from the request.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
protected function credentials(Request $request)
{
if(filter_var($request->email, FILTER_VALIDATE_EMAIL)){
return $request->only($this->username(), 'password');
}
$request->merge(['id' => $request->email]);
return $request->only('id', 'password');
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Support\Str;
use Illuminate\Auth\Events\PasswordReset;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Get the response for a successful password reset.
*
* @param $request
* @param string $response
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
protected function sendResetResponse($request, $response)
{
return $this->respondNoContent();
}
/**
* Reset the given user's password.
*
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
* @param string $password
* @return void
*/
protected function resetPassword($user, $password)
{
$this->setUserPassword($user, $password);
$user->setRememberToken(Str::random(60));
$user->save();
event(new PasswordReset($user));
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Prettus\Repository\Traits\Respondable;
use App\Events\ActionCalled;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, Respondable;
public function gateAction($repository, $request, $id)
{
if(!$repository instanceof \Prettus\Repository\Contracts\RepositoryInterface){
throw new \Exception('The parameter $repository must be instance of Prettus\Repository\Contracts\RepositoryInterface', 1);
}
if(!$request->filled('action')){
return null;
}
$request->validate([
'action' => 'string',
'params' => 'nullable|json',
]);
$data = $repository->find($id);
if(!method_exists($data, 'callAction')){
throw new \Exception('The class ' . get_class($data) . ' must use App\Traits\ActionCallable trait', 1);
}
$data->callAction($request->action, $request->params);
event(new ActionCalled($data, $request->action, json_decode($request->params)));
return $data;
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}

69
app/Http/Kernel.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
EnsureFrontendRequestsAreStateful::class,
'throttle:120,1',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'auth.active' => \App\Http\Middleware\EnsureUserIsActive::class,
];
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use Closure;
class EnsureUserIsActive
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(!$request->user()->active){
throw new \App\Exceptions\AccountNotActive;
}
return $next($request);
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
return $next($request);
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Attachment;
use Illuminate\Foundation\Http\FormRequest;
use App\Entities\Document;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Document::find($this->document_id)->creator_id == $this->user()->id;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'document_id' => 'required|exists:documents,id',
'attachments' => 'required|file',
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Attachment;
use Illuminate\Foundation\Http\FormRequest;
use App\Entities\Attachment;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Attachment::find($this->attachment)->document->creator_id == $this->user()->id;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Attachment;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Attachment;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Http\Requests\Attachment;
use Illuminate\Foundation\Http\FormRequest;
use App\Entities\Document;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Document::find($this->document_id)->creator_id == $this->user()->id;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'document_id' => 'nullable|exists:documents,id',
'name' => 'nullable|string',
'extension' => 'nullable|string',
'size' => 'nullable|numeric',
'path' => 'nullable|string',
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Book;
use Illuminate\Foundation\Http\FormRequest;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý sổ văn bản');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|numeric|unique:books,id,'.$this->book,
'name' => 'required|string',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Book;
use Illuminate\Foundation\Http\FormRequest;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý sổ văn bản');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Book;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Book;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Book;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý sổ văn bản');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|numeric|unique:books,id,'.$this->book,
'name' => 'nullable|string',
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Department;
use Illuminate\Foundation\Http\FormRequest;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý phòng ban');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'required|string|alpha_dash|max:7|unique:departments,id,'.$this->department,
'name' => 'required|string',
'tel' => 'nullable|alpha_num|max:15|unique:departments,tel,'.$this->tel,
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Department;
use Illuminate\Foundation\Http\FormRequest;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý phòng ban');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Department;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Department;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Department;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý phòng ban');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|string|alpha_dash|max:7|unique:departments,id,'.$this->department,
'name' => 'nullable|string',
'tel' => 'nullable|alpha_num|max:15',
];
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Http\Requests\Document;
use Illuminate\Foundation\Http\FormRequest;
use App\Entities\Book;
use Illuminate\Support\Str;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$typeName = Str::lower(Book::find($this->book_id)->name);
return $this->user()->hasPermissionTo('Quản lý '. $typeName);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|numeric|unique:documents,id',
'symbol' => 'nullable|string|max:30|unique:documents,symbol',
'abstract' => 'nullable|string',
'book_id' => 'required|exists:books,id',
'type_id' => 'required|exists:document_types,id',
'signer_id' => 'required|exists:signers,id',
'creator_id' => 'required|exists:users,id',
'writer_id' => 'nullable|exists:users,id',
'effective_at' => 'required|date',
'sign_at' => 'nullable|date',
'publisher_id' => 'required|exists:organizes,id',
'attachments.*' => 'nullable|file',
'link_id' => 'nullable|exists:documents,id',
];
}
/**
* Get all of the input and files for the request.
*
* @param array|mixed|null $keys
* @return array
*/
public function all($keys = null)
{
$data = parent::all($keys);
$data['creator_id'] = $this->user()->id;
return $data;
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Document;
use Illuminate\Foundation\Http\FormRequest;
use App\Entities\Document;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Document::find($this->document)->creator_id == $this->user()->id;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Http\Requests\Document;
use Illuminate\Foundation\Http\FormRequest;
class ExportRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Báo cáo thống kê');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'book' => 'nullable|exists:books,id',
'type' => 'nullable|exists:document_types,id',
'from' => 'nullable|date',
'to' => 'nullable|date',
'export' => 'required|in:Xlsx,Csv,Xls,Html',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Document;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Document;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Http\Requests\Document;
use Illuminate\Foundation\Http\FormRequest;
use App\Entities\Document;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Document::find($this->document)->creator_id == $this->user()->id;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|numeric|unique:documents,id,'.$this->document,
'symbol' => 'nullable|string|max:30',
'abstract' => 'nullable|string',
'book_id' => 'nullable|exists:books,id',
'type_id' => 'nullable|exists:document_types,id',
'signer_id' => 'nullable|exists:signers,id',
'writer_id' => 'nullable|exists:users,id',
'effective_at' => 'nullable|date',
'sign_at' => 'nullable|date',
'publisher_id' => 'nullable|exists:organizes,id',
'link_id' => 'nullable|exists:documents,id',
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\DocumentType;
use Illuminate\Foundation\Http\FormRequest;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý loại văn bản');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'required|alpha_num|max:2|unique:document_types,id',
'name' => 'required|string',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\DocumentType;
use Illuminate\Foundation\Http\FormRequest;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý loại văn bản');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\DocumentType;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\DocumentType;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\DocumentType;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý loại văn bản');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|alpha_num|max:2|unique:document_types,id,'.$this->document_type,
'name' => 'nullable|string',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Me;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Http\Requests\Me;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'nullable|string',
'email' => 'nullable|email',
'password' => 'nullable|min:6|max:32|confirmed',
'tel' => 'nullable|string',
'birthday' => 'nullable|date',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Organize;
use Illuminate\Foundation\Http\FormRequest;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý nơi ban hành');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Organize;
use Illuminate\Foundation\Http\FormRequest;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý nơi ban hành');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Organize;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Organize;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Organize;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý nơi ban hành');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Permission;
use Illuminate\Foundation\Http\FormRequest;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý quyền');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'nullable|string',
'guard_name' => 'nullable|string',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Permission;
use Illuminate\Foundation\Http\FormRequest;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý quyền');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Permission;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Permission;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Permission;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý quyền');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'nullable|string',
'guard_name' => 'nullable|string',
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Role;
use Illuminate\Foundation\Http\FormRequest;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý nhóm');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|string',
'guard_name' => 'nullable|string',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Role;
use Illuminate\Foundation\Http\FormRequest;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý nhóm');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Role;
use Illuminate\Foundation\Http\FormRequest;
class GivePermissionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Phân quyền');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Role;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Role;
use Illuminate\Foundation\Http\FormRequest;
class RevokePermissionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Phân quyền');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Role;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Role;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý nhóm');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'nullable|string',
'guard_name' => 'nullable|string',
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Signer;
use Illuminate\Foundation\Http\FormRequest;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý người ký');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|numeric|unique:signers,id',
'name' => 'required|string',
'description' => 'nullable|string',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Signer;
use Illuminate\Foundation\Http\FormRequest;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý người ký');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Signer;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Signer;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Signer;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý người ký');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|numeric|unique:signers,id,'.$this->signer,
'name' => 'nullable|string',
'description' => 'nullable|string',
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Title;
use Illuminate\Foundation\Http\FormRequest;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý chức danh');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'required|string|alpha_dash|max:30|unique:titles,id',
'name' => 'required|string',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Title;
use Illuminate\Foundation\Http\FormRequest;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý chức danh');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Title;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Title;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Title;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý chức danh');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|string|alpha_dash|max:30|unique:titles,id,'.$this->title,
'name' => 'nullable|string',
];
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý người dùng');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|string',
'email' => 'required|email|unique:users,email',
'password' => 'required|min:6|max:32|confirmed',
'tel' => 'nullable|string|unique:users,tel',
'birthday' => 'nullable|date',
'department_id' => 'nullable|exists:departments,id',
'title_id' => 'nullable|exists:titles,id',
'active' => 'nullable|boolean',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class DestroyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý người dùng');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class ExportRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý người dùng');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'export' => 'required|in:Xlsx,Csv,Xls,Html',
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class GivePermissionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Phân quyền');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class GiveRoleRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Phân quyền');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class ImportRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý người dùng');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'data' => 'required|file:Xlsx'
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class IndexRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->hasPermissionTo('Quản lý người dùng');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|string|unique:users,id,'.$this->user,
'name' => 'nullable|string',
'email' => 'nullable|email|unique:users,email,'.$this->user,
'password' => 'nullable|min:6|max:32|confirmed',
'tel' => 'nullable|string',
'birthday' => 'nullable|date',
'department_id' => 'nullable|exists:departments,id',
'title_id' => 'nullable|exists:titles,id',
'active' => 'nullable|boolean',
];
}
}