- Form Request array syntax: Convert pipe (|) delimited validation rules from strings into an array of validation rules while using Laravel Rule objects where available

- Streamline order methods: Streamline query builder orderBy calls with asc and desc arguments.
- delete some old Request-Clases
This commit is contained in:
Arno Kaimbacher 2022-08-12 06:52:06 +00:00
parent 6156bdf0c6
commit 50ceeb193b
18 changed files with 143 additions and 128 deletions

View File

@ -53,7 +53,7 @@ class SitelinkController extends Controller
->whereYear('server_date_published', '>=', $from)
->whereYear('server_date_published', '<', $until);
$documents = $select->orderBy('publish_id', 'asc')
$documents = $select->orderBy('publish_id')
->get();
//$this->years = Dataset::select(DB::raw('YEAR(server_date_modified) as server_date_modified'))

View File

@ -64,7 +64,7 @@ class DoiController extends Controller
{
$datasets = Dataset::query()
->has('identifier')
->orderBy('server_date_modified', 'desc')
->orderByDesc('server_date_modified')
->get();
return View::make('workflow.doi.index', [
'datasets' => $datasets,

View File

@ -87,7 +87,7 @@ class EditorController extends Controller
$query->whereIn('server_state', ['editor_accepted', 'rejected_reviewer', 'reviewed', 'published'])
->where('editor_id', $user_id)->doesntHave('identifier', 'and');
})
->orderBy('server_date_modified', 'desc')
->orderByDesc('server_date_modified')
->get();
// return View::make('workflow.editor.index', compact('datasets'));
return View::make('workflow.editor.index', [

View File

@ -47,7 +47,7 @@ class SubmitController extends Controller
'released', 'editor_accepted', 'approved', 'reviewed', 'rejected_editor', 'rejected_reviewer'])
->where('account_id', $user_id)
->with('user:id,login')
->orderBy('server_date_modified', 'desc')
->orderByDesc('server_date_modified')
->get();
return View::make('workflow.submitter.index', [
'datasets' => $myDatasets,

View File

@ -30,7 +30,7 @@ class UserController extends Controller
//}
$users = User::with('roles')
->orderBy('id', 'DESC')
->orderByDesc('id')
->paginate(5);
return view('settings.access.user.user', compact('users'))
->with('i', ($request->input('page', 1) - 1) * 5);

View File

@ -27,8 +27,13 @@ class CollectionRequest extends Request
public function rules()
{
return [
'name' => 'required|max:255',
'role_id' => 'required',
'name' => [
'required',
'max:255',
],
'role_id' => [
'required',
],
];
}
}

View File

@ -24,8 +24,13 @@ class DocumentRequest extends Request
public function rules()
{
return [
'type' => 'required|min:3',
'server_state' => 'required',
'type' => [
'required',
'min:3',
],
'server_state' => [
'required',
],
// 'author' => 'required|min:4',
// 'stock' => 'required|integer',
// 'year' => 'required|integer|min:4'

View File

@ -24,15 +24,40 @@ class LicenseRequest extends Request
public function rules()
{
return [
'desc_text' => 'max:4000',
'language' => 'max:3',
'link_licence' => 'required|url:max:255',
'link_logo' => 'url|max:255',
'mime_type' => 'max:30',
'name_long' => 'required|min:5|max:255',
'sort_order' => 'required|integer',
'active' => 'required|boolean',
'pod_allowed' => 'required|boolean'
'desc_text' => [
'max:4000',
],
'language' => [
'max:3',
],
'link_licence' => [
'required',
'url:max:255',
],
'link_logo' => [
'url',
'max:255',
],
'mime_type' => [
'max:30',
],
'name_long' => [
'required',
'min:5',
'max:255',
],
'sort_order' => [
'required',
'integer',
],
'active' => [
'required',
'boolean',
],
'pod_allowed' => [
'required',
'boolean',
],
];
}
}

View File

@ -28,7 +28,10 @@ class UpdatePageRequest extends Request
public function rules()
{
return [
'en_title' => 'required|max:191'
'en_title' => [
'required',
'max:191',
],
// 'description_en' => 'required'
];
}

View File

@ -1,30 +0,0 @@
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class PeminjamanRequest extends Request
{
/**
* 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

@ -1,29 +0,0 @@
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class PeriodeRequest extends Request
{
/**
* 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 [
'days' => 'required|integer'
];
}
}

View File

@ -24,17 +24,45 @@ class CreatePersonRequest extends Request
public function rules()
{
return [
'academic_title' => 'nullable|min:2|max:255',
'last_name' => 'required|min:3|max:255|unique_with:persons,first_name,date_of_birth',
'first_name' => 'required|min:3|max:255',
'email' => 'required|email|max:50|unique:persons,email',
'academic_title' => [
'nullable',
'min:2',
'max:255',
],
'last_name' => [
'required',
'min:3',
'max:255',
'unique_with:persons,first_name,date_of_birth',
],
'first_name' => [
'required',
'min:3',
'max:255',
],
'email' => [
'required',
'email',
'max:50',
'unique:persons,email',
],
// 'email' => [
// 'required', 'email', 'max:100',
// Rule::unique('persons')->ignore($user->id),
// ],
'identifier_orcid' => 'nullable|min:19|max:50',
'status' => 'required|boolean',
'date_of_birth' => 'nullable|date'
'identifier_orcid' => [
'nullable',
'min:19',
'max:50',
],
'status' => [
'required',
'boolean',
],
'date_of_birth' => [
'nullable',
'date',
],
];
}
}

View File

@ -26,17 +26,45 @@ class EditPersonRequest extends Request
public function rules()
{
return [
'academic_title' => 'nullable|min:2|max:255',
'last_name' => 'required|min:3|max:255|unique_with:persons,first_name,date_of_birth',
'first_name' => 'required|min:3|max:255',
'email' => 'required|email|max:50|unique:persons,email',
'academic_title' => [
'nullable',
'min:2',
'max:255',
],
'last_name' => [
'required',
'min:3',
'max:255',
'unique_with:persons,first_name,date_of_birth',
],
'first_name' => [
'required',
'min:3',
'max:255',
],
'email' => [
'required',
'email',
'max:50',
'unique:persons,email',
],
// 'email' => [
// 'required', 'email', 'max:100',
// Rule::unique('persons')->ignore($user->id),
// ],
'identifier_orcid' => 'nullable|min:19|max:50',
'status' => 'required|boolean',
'date_of_birth' => 'nullable|date'
'identifier_orcid' => [
'nullable',
'min:19',
'max:50',
],
'status' => [
'required',
'boolean',
],
'date_of_birth' => [
'nullable',
'date',
],
];
}
}

View File

@ -24,9 +24,19 @@ class ProjectRequest extends Request
{
return [
'name' => 'required|min:3|max:255',
'label' => 'required|min:3|max:20',
'description' => 'required'
'name' => [
'required',
'min:3',
'max:255',
],
'label' => [
'required',
'min:3',
'max:20',
],
'description' => [
'required',
],
];
}
}

View File

@ -1,30 +0,0 @@
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class ShelfRequest extends Request
{
/**
* 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 [
'shelf' => 'required'
];
}
}

View File

@ -301,7 +301,7 @@ class Dataset extends Model
$result = Dataset::select('server_date_published')
->where('server_date_published', '<>', null)
->where('server_state', 'published')
->orderBy('server_date_published', 'asc')
->orderBy('server_date_published')
->first();
//->server_date_published;
return $result;

View File

View File

@ -70,7 +70,7 @@ $appRoutes = function () {
->whereYear('server_date_published', '>=', $from)
->whereYear('server_date_published', '<', $until);
$documents = $select->orderBy('publish_id', 'asc')
$documents = $select->orderBy('publish_id')
->get();
return response()
->json($documents)
@ -118,7 +118,7 @@ $appRoutes = function () {
$query = $query->orderBy($sortCol, $sortDir);
}
} else {
$query = $query->orderBy('id', 'asc');
$query = $query->orderBy('id');
}
//handle filter