laravel使用carbon从excel导入数据并更改日期格式

时间:2017-12-11 15:08:07

标签: php excel

我有从导入日期从csv到数据库的问题因为日期的格式所以我使用了mutator但是我收到了错误消息:数据丢失

命名空间App;

use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;

class Checks extends Model
  {
     protected $table='checks';
   protected $fillable=
  ['details','postingdate','desription','amonut','type','slip','name','job'];
   protected $primaryKey='id';
    public $timestamps=false;

      public function setPostingdateAttribute($date) {
     $this->attributes['postingdate'] = Carbon::createFromFormat('m/d/yyyy', $date)->format('yyyy-mm-dd');
  }
 }

0 个答案:

没有答案