/**
* indexの月別表示
*
* @return \Illuminate\Http\Response
*/
public function indexToMonthly(Request $request)
{
return redirect('management?year='.$request->year.'&month='.$request->month);
}
クエリパラメータ付きURLを作成し、リダイレクトを行っています。
これしか方法が思い浮かばなかった。
次はリポジトリ。
/**
* 月別予約一覧を取得する
*
* @return ReserveManagement[]
*/
public function getListByMonth($year, $month)
{
return ReserveManagement::where('start_day', '>=', date('Y-m-d', strtotime('first day of '.$year.'-'.$month)))
->where('start_day', '<=', date('Y-m-d', strtotime('last day of '.$year.'-'.$month)))
->get();
}
class ManagementRequest extends FormRequest
{
/**
* 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 [
'name' => 'required|string',
'address' => 'required|string',
'phone' => 'required|digits:11',
'num' => 'required|numeric|digits_between:1,2',
'days' => 'required|numeric|digits_between:1,4',
'start_day' => 'required|date',
];
}
}
use App\Http\Requests\ManagementRequest;
/**
* 登録処理
*/
public function store(ManagementRequest $request)
/**
* 更新処理
*/
public function update(ManagementRequest $request)