laravel-learn-bbs/app/Http/Requests/TopicRequest.php

52 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2018-01-01 04:00:45 +00:00
<?php
namespace App\Http\Requests;
class TopicRequest extends Request
{
public function rules()
{
switch ($this->method()) {
// CREATE
case 'POST':
{
return [
2018-01-01 08:32:20 +00:00
'title' => 'required|max:50',
'category_id' => 'required|integer',
'body' => 'required|min:3'
2018-01-01 04:00:45 +00:00
];
}
// UPDATE
case 'PUT':
case 'PATCH':
{
return [
// UPDATE ROLES
];
}
case 'GET':
case 'DELETE':
default:
{
return [];
};
}
}
2018-01-01 08:32:20 +00:00
public function attributes()
{
return [
'title' => '标题',
'category_id' => '类别',
'body' => '内容'
];
}
2018-01-01 04:00:45 +00:00
public function messages()
{
return [
// Validation messages
];
}
}