Code/PHP

Laravel Tips ) 레코드 존재 확인 용으로 find함수와 if함수의 조합 비추천

kolbe_starziki 2021. 2. 23. 08:44
 

Laravel Daily

Tips, tutorials, and demo-projects based on Laravel framework and technology around it. Host: Povilas Korop

www.youtube.com

레코드 존재를 확인하기 위한 용도로 if문과 find함수의 조합를 쓰지 말라.findOrFail() 혹은 optional을 쓰자.

 

yt3.ggpht.com/d7WPOrvEaFbXc2Y06b1y3RZhfEPOtnLfsTQkqttAY8YpPlr0ebVbF_I_P19B-c46xtFAu4pkL-YZ3g=s640-c-fcrop64=1,00200000ffdfffff-nd