Thursday, November 14, 2019

How to create migration load into subfolder ?

Note  : If create table in  migration sub folder 

Create Table 

php artisan make:migration create_sample_table --path=database/migrations/sub_folder


Note : If multiple Sub Folder migration 

 # php artisan migrate --path=database/migrations/sub_folder1
 # php artisan migrate --path=database/migrations/sub_folder2

Note: If single subfolder migration:

 # php artisan migrate --path=/database/migrations/*

How to create laravel Custom helper ?

First Example :

Step#01

Create a HrHelper.php file in your app/Helpers folder and load it up with composer.json:

"autoload": {
    "classmap": [
        ...
    ],
    "psr-4": {
        "App\\": "app/"
    },
    "files": [
        "app/Helpers/HrHelper.php" // <---- ADD THIS
    ]
},


Step#02

After adding that to your composer.json file, run the following command:

composer dump-autoload

Step#03

#Apply your function in SampleControlle


<?php

namespace App\Http\Controllers\HR\Employee;

public function index(Request $request){

$headPersonList =getHeadPersonList();
return view('employee',compact('headPersonList'));

}




Second Example :

Step#01

Create your helper Helpers/HrHelper.php


namespace App\Helpers;

use App\Model\HR\HrManageEmployee;

class HrHelper
{

    public static function getHeadPersonList(){

        $details = HrManageEmployee::where('status',0)
            ->select('id','user_name')
            ->get();

        foreach ($details as $row) {
            $headPersonListData[] = [
                'id' => $row->id,
                'user_name' => $row->user_name,
            ];
        }

        return $headPersonListData;
    }
}


Step#02

Create an  alias :

aliases' => [
     ...
        'Helper' => App\Helpers\HrHelper::class,

]


Step#03

composer dump-autoload


Step#04

#Apply your function in SampleControlle


<?php

 namespace App\Http\Controllers\HR\Employee;
 use App\Helpers\HrHelper;


 public function index(Request $request){

$headPersonList =HrHelper::getHeadPersonList();
return view('employee',compact('headPersonList'));

}

Ajax load lage with laravel.

 step-1:  HTML <div class="row">                     <div class="col-lg-12">                           <d...