Current File : //home/tradevaly/demo.tradevaly.com.bd/app/Models/Country.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Country extends Model
{
    use HasFactory;
    use SoftDeletes;
    
    protected $fillable = [
        'created_user_id', 'modified_user_id', 'deleted_user_id', 'name', 'iso_code_two_digit', 'iso_code_three_digit', 'calling_code', 'currency_name', 'currency_sign', 'flag', 'status', 'updated_at'
    ];


    protected function countryList()
    {
    		
    		$country = [];

    		$country['countryNameOnly'] = Country::where('status', 1)->orderBy('name','ASC')->pluck('name','id')->all();
    		
    		$country['countryCodeOnly'] = Country::where('status', 1)->orderBy('name','ASC')->pluck('calling_code','id')->all();
    		
    		$country['countryFlagOnly'] = Country::where('status', 1)->orderBy('name','ASC')->pluck('flag','id')->all();

    		$country['countryCurrencySignOnly'] = Country::where('status', 1)->where('currency_sign', '!=', '')->orderBy('name','ASC')->pluck('currency_sign','id')->all();
    	
    		
    		$data = Country::where('status', 1)->get()->toArray();

    		
    		foreach ($data as $key => $value) {
    			
    			$country['all'][$value['id']]['name'] =  $value['name'];
    			$country['all'][$value['id']]['iso_code_two_digit'] =  $value['iso_code_two_digit'];
    			$country['all'][$value['id']]['iso_code_three_digit'] =  $value['iso_code_three_digit'];
    			$country['all'][$value['id']]['calling_code'] =  $value['calling_code'];
    			$country['all'][$value['id']]['currency_name'] =  $value['currency_name'];
    			$country['all'][$value['id']]['currency_sign'] =  $value['currency_sign'];
    			$country['all'][$value['id']]['flag'] =  $value['flag'];
    		
    		}


    	return $country;
    }



    protected function callingCodeList()
    {
            
            $country = [];

            $country['countryNameOnly'] = Country::where('status', 1)->orderBy('name','ASC')->pluck('name','id')->all();
            
            $country['countryCodeOnly'] = Country::where('status', 1)->orderBy('name','ASC')->pluck('calling_code','id')->all();
            
            $country['countryFlagOnly'] = Country::where('status', 1)->orderBy('name','ASC')->pluck('flag','id')->all();
        
            
            $data = Country::where('status', 1)->get()->toArray();

            
            foreach ($data as $key => $value) {
                
                $country['all'][$value['id']]['name'] =  $value['name'];
                $country['all'][$value['id']]['calling_code'] =  $value['calling_code'];
                $country['all'][$value['id']]['flag'] =  $value['flag'];
            
            }


        return $country;
    }


}