1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Http/Requests/Migration/UploadMigrationFileRequest.php

49 lines
1.1 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\Requests\Migration;
use App\Http\Requests\Request;
class UploadMigrationFileRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
2023-08-01 15:28:30 +02:00
/** @var \App\Models\User $user */
$user = auth()->user();
return $user->isAdmin();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
2023-08-01 15:28:30 +02:00
public function rules(): array
{
2020-02-20 21:58:38 +01:00
$rules = [
'migration' => [],
];
2020-02-20 21:58:38 +01:00
/* We'll skip mime validation while running tests. */
if (app()->environment() !== 'testing') {
$rules['migration'] = ['required', 'file', 'mimes:zip'];
2020-02-20 21:58:38 +01:00
}
return $rules;
}
}