Shilpa Kalangutkar

Shilpa Kalangutkar

45 Articles Published

Articles by Shilpa Kalangutkar

Page 2 of 5

How to insert raw data in MySQL database in Laravel?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 6K+ Views

In Laravel, you can insert raw data into MySQL database tables using the Query Builder tool. This requires including the Illuminate\Support\Facades\DB facade or adding use DB; at the top of your controller. Prerequisites: Ensure Laravel is installed and a MySQL database connection is configured in your .env file. Assume we have created a table named students using the CREATE statement as shown below − CREATE TABLE students( id INTEGER NOT NULL PRIMARY KEY, ...

Read More

How to call a controller function inside a view in Laravel 5?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 4K+ Views

In Laravel, you can call controller methods directly within views using several approaches. While this is generally discouraged in favor of proper MVC separation, Laravel provides multiple ways to achieve this when necessary. Method 1: Direct Static Call The simplest approach is to call the controller method directly using its fully qualified namespace − Method 2: Using Import Statement You can import the controller class first, then call the method − Method 3: Blade Template Syntax For Blade templates, you can use double curly braces − ...

Read More

How to get the contents of the HTTP Request body in Laravel?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 12K+ Views

In Laravel, you can retrieve HTTP request body contents using the Illuminate\Http\Request class. This class provides several methods to access input data, cookies, and files from HTTP requests in different formats. HTTP Request Body name: John Doe email: john@example.com age: 25 Laravel Request Methods Using $request->all() Method The all() method retrieves all input data from the request and returns it as an array − Output Array ( ...

Read More

How to Insert a value to a hidden input in Laravel Blade?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 5K+ Views

In Laravel Blade templates, you can insert values into hidden input fields using Blade syntax or Laravel's Form helpers. Hidden fields are commonly used to store data like CSRF tokens, user IDs, or secret keys that need to be submitted with forms but should not be visible to users. Basic Hidden Input with Blade Syntax The simplest way is to use standard HTML with Blade template syntax − Route Setup Basic Blade Template (hello.blade.php) {{$mymsg}} Welcome to Tutorialspoint Adding Hidden Input with Dynamic Values ...

Read More

How to change variables in the .env file dynamically in Laravel?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 9K+ Views

In Laravel, the .env file contains environment variables that configure your application's behavior across different environments (local, staging, production). While these variables are typically static, you can modify them dynamically using PHP file operations. Understanding the .env File The .env file contains key-value pairs for configuration − APP_NAME=Laravel APP_ENV=local APP_KEY=base64:BUdhVZjOEzjFihHKgt1Cc+gkQKPoA4iH98p5JwcuNho= APP_DEBUG=true APP_URL=http://localhost DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=test DB_USERNAME=root DB_PASSWORD= These variables are used throughout Laravel's configuration files in the config/ folder and should not be committed to version control as they vary per environment. Fetching Current Environment You can retrieve the current ...

Read More

How to decode JSON objects in Laravel and apply for each loop on that?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 11K+ Views

The json_decode() method is a PHP built-in function that helps convert a JSON string into a PHP object or associative array. It takes the input value as a string and returns a readable PHP object or array that can be easily looped through using foreach. Basic JSON Decoding Following is an example of the json_decode() method − stdClass Object ( [Neha] => 35 [Arbaaz] => 37 [Rehan] => 43 ) Looping Through JSON Objects The JSON object ...

Read More

How to create and update Laravel Eloquent?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 16K+ Views

Laravel Eloquent provides powerful methods to create or update records in your database. The updateOrCreate() method and DB facade's updateOrInsert() method offer elegant solutions for upsert operations. Prerequisites: You need Laravel installed with a configured database connection and a Student model created. Assume we have created a table named students using the CREATE statement as shown below − CREATE TABLE students( id INTEGER NOT NULL PRIMARY KEY, ...

Read More

How to extract raw form data in Laravel?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 7K+ Views

In Laravel, you can extract raw form data using several methods depending on your needs. Laravel's Request class provides various methods to access form data in different formats − raw strings, arrays, or individual field values. Using file_get_contents() The file_get_contents() function with php://input returns the raw POST data as a string. This method captures the exact data sent from the form ? _token=zHuIkXpqcRqvZO4vTgxH0fFk5fCmvqSavrCjHVMi&username=testing&password=abcd Using getContent() Method The getContent() method on Laravel's Request class returns the raw request body as a string − similar to file_get_contents() but more Laravel-specific ? ...

Read More

How to get a list of registered route paths in Laravel?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 4K+ Views

In Laravel, you can retrieve a list of all registered route paths using several methods. All routes are stored in the routes/ folder, and you'll need to include the Route facade to work with them ? Make sure Laravel is installed and configured properly before running these examples. Using Artisan Command The simplest way to view all routes is using the artisan command ? php artisan route:list +--------+----------+---------------------+------+-------------------------------------------------------------+------------------------------------------+ | Domain | Method | URI ...

Read More

How to delete a file from the public folder in Laravel?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 5K+ Views

In Laravel, you can delete files from the public folder using the File facade or PHP's built-in unlink() function. The File facade provides convenient methods for file operations. To work with File facade you need to include the class as shown below − use Illuminate\Support\Facades\File; Using File::delete() Method The delete() method from the File facade can delete single files or multiple files. It accepts a file path or an array of file paths ? File deleted successfully Using PHP unlink() Function The unlink() function is ...

Read More
Showing 11–20 of 45 articles
Advertisements