Found 52 Articles for Laravel

How to get the server IP with Laravel?

Shilpa Kalangutkar
Updated on 29-Aug-2022 09:00:15

7K+ Views

The server IP will be the IP address of the server you are connected to. When you are working with Laravel to get the server IP you can make use of $_SERVER['SERVER_ADDR']. The $_SERVER variable acts as a global variable in PHP. It holds details like header information, script location, and other miscellaneous details. Example 1 The following example retrieves the details of the $_SERVER global variable.

How to check if a Laravel collection is empty?

Shilpa Kalangutkar
Updated on 29-Aug-2022 08:52:14

18K+ Views

Before we answer the above question, let us first understand what collections are in Laravel. Collection in Laravel is an API wrapper that helps you deal with different operations to be performed on arrays. It makes use of the class Illuminate\Support\Collection to deal with arrays in Laravel. To create a collection from a given array you need to make use of the collect() helper method that returns a collection instance. Later you can use a chain of methods like converting to lowercase and sorting on the collection instance. Example  The example in this section demonstrates how to create a collection from ... Read More

Advertisements