
Published 2021. 12. 28. 15:42
반응형
프론트 php
토큰값 불러오기
$mb_id = $request->user_info['mb_id'];
반복문해서 저장
foreach($data as $key) {
$row = new EstimateList();
$row->partnumber = $key["partnumber"];
$row->reg_date = $reg_date;
$row->save();
}
배열값 풀기
$request->input());
$request->all());
객체, 배열 값 가져오는 방법
객체
obj->대상
배열
arr['대상']
try, catch
try{
} catch (\Exception $e) {
echo 'Message: ' . $e->getMessage();
return false;
}
json을 디코드해서 데이터 가져오기
$data = json_decode($request->getContent());
Response 2가지 방법
return Response::json([
'status' => 200,
'msg' => 'QnA 상세페이지 정보',
'data' => $return_data
]);
try{
return [
'result' => true,
'data' => $userData,
];
} catch(\Throwable $e) {
throw new \Exception( "유저 정보 불러오기 msg: {$e->getMessage()}", 500 );
}
현재시간
$now = Carbon::now('Asia/Seoul');
날짜 비교
strotime 사용
@if ( strtotime(date("Y-m-d",time())) === strtotime($list->po_datetime->timezone(config('panda.timezone'))->format('Y-m-d')))
날짜 비교하는 여러가지 코드
dd(strtotime($list->po_datetime->timezone(config('panda.timezone'))->format('Y-m-d')));
dd($list->po_datetime->timezone(config('panda.timezone'))->format('Y-m-d'));
dd(strtotime(date("Y-m-d",time())));
dd(date("Y-m-d",time()));
dd(new DateTime(date("Y-m-d"))->format('Y-m-d') );
dd(strtotimenew DateTime(date("Y-m-d")) === $list->po_datetime->timezone(config('panda.timezone'))->format('Y-m-d'));
dd(new DateTime(date("Y-m-d")) === $list->po_datetime->timezone(config('panda.timezone'))->format('Y-m-d'));
반응형
'Backend 언어 및 프레임워크 > PHP' 카테고리의 다른 글
laravel) request로부터 IP 주소 얻기 (0) | 2021.12.20 |
---|---|
PHP) 문법 사이트 (0) | 2021.11.17 |
PHP) 함수 (0) | 2021.11.16 |
PHP) URL 파라미터 (0) | 2021.11.16 |
PHP) 문자열 및 변수 (0) | 2021.11.16 |