You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
954 B
52 lines
954 B
<?php
|
|
|
|
namespace App\Http\Requests\Backups;
|
|
|
|
use App\Http\Requests\Request;
|
|
|
|
class BackupUploadRequest extends Request {
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return auth()->user()->can('manage_backups');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
'backup_file' => 'required|sql_zip'
|
|
];
|
|
}
|
|
|
|
public function messages()
|
|
{
|
|
return [
|
|
'file.sql_zip' => 'Isian file harus dokumen berjenis .zip, .gz atau .sql',
|
|
];
|
|
}
|
|
|
|
protected function getValidatorInstance()
|
|
{
|
|
$validator = parent::getValidatorInstance();
|
|
|
|
$validator->addImplicitExtension('sql_zip', function($attribute, $value, $parameters) {
|
|
if ($value)
|
|
return in_array($value->getClientOriginalExtension(), ['zip','gz','sql']);
|
|
|
|
return false;
|
|
});
|
|
|
|
return $validator;
|
|
}
|
|
|
|
}
|