Nowadays, Laravel is known as the best PHP framework for building modern, full-stack web applications. Whether you are new to PHP or web frameworks or have years of experience, Laravel is a progressive framework that can grow with you. So in this article, I will share some amazing tips and tricks about laravel that can elevate your coding level and helps you in your coding journey.
In the Laravel 8.81 getOrPut method to Collections that simplifies the use-case where you want to either get an existing key or insert a value if it doesn't exist and return the value.
// Instead of this JobPost::where('company', 'laravel') ->where('job_type', 'full time') ->get(); // You can pass an array JobPost::where(['company' => 'laravel', 'job_type' => 'full time']) ->get(); Return the primary keys from the models collection