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,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',
];
}
}