$this->auth(), 'send_time' => Carbon::now() ]; $fields = ['*']; $sort = '`send_time` desc'; $page = request('page', 1); $limit = request('limit', 20); return DiaryLetterFacade::getList($conditions, $fields, $sort, $page, $limit); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $data['uid'] = $this->auth(); $data['content'] = $request->content; $now = Carbon::now(); switch ($request->type){ case 1: //半年 $sendTime = $now->addMonths(6); break; case 2: //1年 $sendTime = $now->addYears(1); break; case 3: //2年 $sendTime = $now->addYears(2); break; case 4: //3年 $sendTime = $now->addYears(3); break; case 5: //10年 $sendTime = $now->addYears(10); break; } $data['send_time'] = $sendTime; return DiaryLetterFacade::create($data); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $conditions = [ 'id' => $id, 'uid' => $this->auth(), 'send_time' => Carbon::now() ]; $fields = ['*']; return DiaryLetterFacade::findBy($conditions, $fields); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } }