|
...
|
...
|
@@ -7,7 +7,10 @@ |
|
|
|
*/
|
|
|
|
namespace App\Models\Inquiry;
|
|
|
|
|
|
|
|
use App\Helper\Translate;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 广告询盘表单内容
|
|
...
|
...
|
@@ -62,6 +65,10 @@ class ReInquiryForm extends Model |
|
|
|
*/
|
|
|
|
public static function createInquiry($id, $origin_id, $ad_set_id, $ad_set_name, $ad_id, $ad_name, $full_name, $email, $phone, $whatsapp, $message, $country, $inquiry_date)
|
|
|
|
{
|
|
|
|
if($country){
|
|
|
|
$country_name = self::getCountryName($country);
|
|
|
|
}
|
|
|
|
|
|
|
|
$self = self::where(['id' => $id])->first();
|
|
|
|
if (empty($self)) {
|
|
|
|
$self = new self();
|
|
...
|
...
|
@@ -80,8 +87,29 @@ class ReInquiryForm extends Model |
|
|
|
$self->message = $message;
|
|
|
|
$self->inquiry_date = $inquiry_date;
|
|
|
|
$self->country = $country;
|
|
|
|
$self->country_name = $country_name??'';
|
|
|
|
$self->save();
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function getCountryName($country){
|
|
|
|
if (strlen($country) == 2) {
|
|
|
|
$country = self::getCountry($country);
|
|
|
|
} else {
|
|
|
|
$country = Translate::tran($country, 'zh');
|
|
|
|
}
|
|
|
|
return $country;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getCountry($code)
|
|
|
|
{
|
|
|
|
$cache_key = 'inquiry_world_country';
|
|
|
|
$country_code = Cache::get($cache_key, function () use ($cache_key) {
|
|
|
|
$country_code = DB::table('gl_world_country_city')->where(['pid' => 0])->pluck('chinese_name', 'iso2')->toArray();
|
|
|
|
Cache::put($cache_key, $country_code, 86400);
|
|
|
|
return $country_code;
|
|
|
|
});
|
|
|
|
return empty($country_code[$code]) ? '' : $country_code[$code];
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|