Deploy Angular Project with CI /CD to Hostinger with FTP

 1. creat a folder in your project root folder with name .github 2. create second folder in .github/workflows 3. create file in your .github/workflows/main.yml paste this code in main.yml file on :   push :     branches : main <--- select your branch name name : 🚀 Deploy website on push jobs :   web-deploy :     name : 🎉 Deploy     runs-on : ubuntu-latest     steps :     - name : 🚚 Get latest code       uses : actions/checkout@v3     - name : Use Node.js 18       uses : actions/setup-node@v2       with :         node-version : '18'           - name : 🔨 Build Project       run : |         npm install               npm run build       - name : 📂 Sync files       uses : SamKirkland/FTP-Deploy-Action@v4.3.4   ...

Export Excel file from api in Laravel

        Installation 

1. composer require maatwebsite/excel

2.php artisan make:export YourExcelExport

3. php artisan make:controller ExcelController

 path app/export and  paste in your file 


<?php

namespace App\Exports;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;

class YourExportClassName implements FromCollection ,WithHeadings
{
    /**
    * @return \Illuminate\Support\Collection
    */
    protected $data;
   
    public function __construct($data)
    {
        $this->data = $data;
    }
   
    public function collection()
    {
        return $this->data;
    }
   
    public function headings(): array
    {
        // Define the headings for your Excel file here.
        return [
           
            'Name',
            'Email',
            'Employee ID',
            'Designation',
            'State',
            'City',
            'Department',
            'Merchant Name',
            'Merchant Shop Name',
            'Merchant Pincode',
            'Merchant Address',
            'Merchant occupation'
        ];
       
    }
}



4. this is your controller  public function export()
    {
        $userData = Auth::user();
        $data = User::join('survey_forms', 'users.id', '=', 'survey_forms.user_id')
            ->where('users.reporting_to', $userData->id)
            ->select('users.name','users.email','empid','designation','state','city','department', 'survey_forms.merchant_name','survey_forms.merchant_shop_name','survey_forms.pincode','survey_forms.address','survey_forms.occupation')
            ->get();
   
        $fileName = 'example.xlsx';
        Excel::store(new YourExportClassName($data), $fileName, 'public');
        return response()->json(['download_url' => 'http::rebliss.in/sfa/storage/app/public/'.$fileName]);
     }



5 .  paste below command in your config/filesystem 


 'public' => [
            'driver' => 'local',
            'root' => public_path(),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
            'throw' => false,
        ],
              

                                                                       

Comments

Popular posts from this blog

Ms Office 2019 activation link