app\models\Client::getImportMap PHP Method

getImportMap() public static method

public static getImportMap ( ) : array
return array
    public static function getImportMap()
    {
        return ['first' => 'first_name', 'last' => 'last_name', 'email' => 'email', 'mobile|phone' => 'phone', 'name|organization' => 'name', 'street2|address2' => 'address2', 'street|address|address1' => 'address1', 'city' => 'city', 'state|province' => 'state', 'zip|postal|code' => 'postal_code', 'country' => 'country', 'note' => 'notes', 'site|website' => 'website', 'vat' => 'vat_number'];
    }

Usage Example

 public function mapCSV($files)
 {
     $data = [];
     foreach ($files as $entityType => $filename) {
         if ($entityType === ENTITY_CLIENT) {
             $columns = Client::getImportColumns();
             $map = Client::getImportMap();
         } else {
             $columns = Invoice::getImportColumns();
             $map = Invoice::getImportMap();
         }
         // Lookup field translations
         foreach ($columns as $key => $value) {
             unset($columns[$key]);
             $columns[$value] = trans("texts.{$value}");
         }
         array_unshift($columns, ' ');
         $data[$entityType] = $this->mapFile($entityType, $filename, $columns, $map);
         if ($entityType === ENTITY_CLIENT) {
             if (count($data[$entityType]['data']) + Client::scope()->count() > Auth::user()->getMaxNumClients()) {
                 throw new Exception(trans('texts.limit_clients', ['count' => Auth::user()->getMaxNumClients()]));
             }
         }
     }
     return $data;
 }