DeveloperBreeze

Laravel Programming Tutorials, Guides & Best Practices

Explore 51+ expertly crafted laravel tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Handling HTTP Requests and Raw Responses in Laravel

Tutorial October 24, 2024
php

It’s important to handle errors gracefully in production. Laravel’s Http facade offers methods to check if a request was successful.

use Illuminate\Support\Facades\Http;

$response = Http::post('https://api.example.com/endpoint', [
    'key1' => 'value1',
    'key2' => 'value2',
]);

if ($response->successful()) {
    dd($response->json()); // Handle successful response
} elseif ($response->failed()) {
    dd('Request failed: ' . $response->body()); // Handle failed request
}

Building a Custom E-commerce Platform with Laravel and Vue.js

Tutorial August 27, 2024
javascript php

Update your resources/views/welcome.blade.php to include the root element for Vue:

<div id="app"></div>
<script src="{{ mix('js/app.js') }}"></script>

Integrating and Using NMI Payment Gateway in Laravel

Tutorial August 14, 2024
php

Create a new file in the app/Services directory named NMI.php.

   namespace App\Services;

   use Illuminate\Support\Facades\Http;

   class NMI
   {
       protected $securityKey, $url;
       protected $production;

       public function __construct()
       {
           $this->production = env('APP_ENV') === 'production';
           $this->securityKey = config('nmi.security_key');
           $this->url = 'https://secure.nmi.com/api/transact.php';
       }
   }