我下載了它在Laravel 5.0創建了一個簡單的應用程序。我在Http \ Requests下找到了一些文件,例如什麼是laravel 5創建自定義的請求類的目的是什麼?
HTTP \請求\ Request.php
<?php namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
abstract class Request extends FormRequest {
//
}
HTTP \請求\管理\ PhotoRequest.php
<?php namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
class PhotoRequest extends FormRequest {
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'language_id' => 'required|integer',
'photo_album_id' => 'required|integer',
];
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
}
什麼是這些類的目的,它是如何生效?
如果您需要在多個位置驗證相同的表單,該怎麼辦?你如何不重複自我 –