diff --git a/app/controller/FollowController.php b/app/controller/FollowController.php index 1e04aa6..e01fa8b 100644 --- a/app/controller/FollowController.php +++ b/app/controller/FollowController.php @@ -139,13 +139,13 @@ class FollowController 'lat'=>Util::getParam($request,'lat',0), 'lng'=>Util::getParam($request,'lng',0), 'address'=>Util::getParam($request,'address'), - 'follow_time'=>Util::getParam($request,'firstFollowtime',0), + 'follow_time'=>strtotime(Util::getParam($request,'firstFollowtime',0)), ]; $res = Follow::create($data); $customer = Customer::find($customer_id); - $customer->follow_last = $res->created_at; + $customer->follow_last = strtotime($res->created_at); $customer->save(); if ($res) { diff --git a/app/model/Customer.php b/app/model/Customer.php index 83367a3..a8d01ef 100644 --- a/app/model/Customer.php +++ b/app/model/Customer.php @@ -90,6 +90,7 @@ class Customer extends Model $customer = Util::formatDate($customer,['follow_last']); $customer['car_type_name'] = empty($customer['car_type_id'])?'':CarType::where(['id'=>$customer['car_type_id']])->value('name'); + $customer['country_name'] = empty($customer['country_id'])?'':Country::where(['id'=>$customer['country_id']])->value('cn_addr'); // $customer['last_follow'] = $last_follow; return $customer; diff --git a/app/model/Follow.php b/app/model/Follow.php index 4456a43..d036ed2 100644 --- a/app/model/Follow.php +++ b/app/model/Follow.php @@ -37,16 +37,20 @@ class Follow extends Model */ public $timestamps = true; + protected $dates = ['created_at', 'updated_at', 'follow_time']; + protected $casts = [ -// 'updated_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式 -// 'created_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式 - 'updated_at' => 'timestamp', // 指定序列化格式 - 'created_at' => 'timestamp', // 指定序列化格式 + 'updated_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式 + 'created_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式 + 'follow_time' => 'datetime:Y-m-d H:i:s', // 指定序列化格式 +// 'updated_at' => 'timestamp', // 指定序列化格式 +// 'created_at' => 'timestamp', // 指定序列化格式 ]; public static function getFollow($follow,$domain = 'https://vehicle-album.oss-cn-beijing.aliyuncs.com') { $follow['type_txt'] = Constants::FOLLOW[$follow['type']]; + $follow['firstFollowtime'] = $follow['follow_time']; $follow['oss_picture'] = $domain.'/'.$follow['picture']; $follow = Util::formatDate($follow); return $follow;