Laravel Essential #Paths

Helper Function # app_path() $path = app_path(); $path = app_path(‘Http/Controllers/Controller.php’); # base_path() $path = base_path(); $path = base_path(‘vendor/bin’); # config_path() $path = config_path(); $path = config_path(‘app.php’); # database_path() $path = database_path(); $path = database_path(‘factories/UserFactory.php’); # mix() $path = mix(‘css/app.css’); #…

Swagger for Laravel

Integration of Swagger in Laravel Application Now here step by step to install and configure the swagger api for laravel documentations. Step 1: Install Swagger open Api Now install the Swagger according to the Laravel version that you have installed….

Laravel HasManyThrough And HasManyThrough Inverse Eloquent Relationship Tutorial Example

Laravel HasManyThrough Eloquent Relationship Tutorial Example   <?php namespace App; use Illuminate\Database\Eloquent\Model; class Country extends Model { public function posts() { return $this->hasManyThrough( Post::class, User::class, ‘country_id’, // Foreign key on users table… ‘user_id’, // Foreign key on posts table… ‘id’,…

আপগ্রেড Laravel 5.7 টু Laravel 7, সমস‌্যা ও সমাধান

আজকে একটা Laravel 5.7 প্রোজেক্টকে Laravel 7 এ আপগ্রেড করতে গিয়ে অদ্ভুত কিছু জিনিসের সম্মুখিন হলাম। ১. এক বারে আপগ্রেড এ Jump করতে গেলে ( Laravel 5.7 to Laravel 7) যেসব Error আসে তা বোঝা কঠিন। যত সার্চ দিছি, সবাই…

Best practice when you write an API

Best practice when you write an API Some of the points to consider while writing an API: Should be Simple. Should be Intuitive. Example: /users/{id}/card-number instead of /users/{id}/pin Should always be consistent. Should avoid camel cases. The normal is to use lower case…

18 Laravel Collection Methods with Example

18 Laravel Collection Methods with Example In this laravel collection methods tutorial, we will discuss about laravel collection methods and it’s uses with simple and easy example. We will illustrate some of the important and useful laravel collection methods. You…

Laravel 5 – Remove Public from URL

Laravel redirect root path to public directory <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ ^$1 [N] RewriteCond %{REQUEST_URI} (\.\w+$) [NC] RewriteRule ^(.*)$ public/$1 RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f…

Laravel Eloquent ORM relation with pivot table

Table sample user id – integer name – string user-role user_id – integer role_id – integer role id – integer title – string   class User extends Model { /** * The roles that belong to the user. */ public…

Complex queries using Eloquent Query in Laravel

Using Eloquent Queries are easy and helpful  but what will you do when you need to do  a complex query like “select fields from table  where (a=1 OR b=1)AND (c=1 OR d=1);” You can make use of the parameter grouping…

Laravel Pivot table working with Eloquent ORM

Here is the pivot table. Will make relation with laravel eloquent. shops – id – name products – id – name product_shop – product_id – shop_id product_shop is called a “pivot” table. Lets make a relation between shops table and…