我需要2个函数添加并更新用户社交用serialize数组到字符串之前插入数据库这里我的代码
<?php
use Illuminate\Database\Eloquent\Model as Model;
class User extends Model{
protected $table = 'user';
protected $primaryKey = 'user_id';
protected $fillable = [
'name',
'email',
'socials',
];
public function getSocialsAttribute($value){
return unserialize($value);
}
public function setSocialsAttribute($value){
settype($value, 'array');
$this->attributes['socials'] = serialize($value);
}
}
并在我的控制器中
$user_id = User::insert($request->post);
带
的帖子数组array(
'name'=>'A',
'email'=>'Test@gmail.com',
'socials'=> array(
'facebook' => 'facebook.com',
'twitter' => 'twiter.com'
)
)
但数据库没有序列化数据!
答案 0 :(得分:4)
我认为它不适用于<script type="text/javascript" src="//code.jquery.com/jquery-1.8.3.js"></script>
<script>;
(function ($) {
$.fn.customerPopup = function (e, intWidth, intHeight, blnResize) {
e.preventDefault();
intWidth = intWidth || '500';
intHeight = intHeight || '400';
strResize = blnResize ? 'yes' : 'no';
var strTitle = typeof this.attr('title') !== 'undefined' ? this.attr('title') : 'Social Share', strParam = 'width=' + intWidth + ',height=' + intHeight + ',resizable=' + strResize, objWindow = window.open(this.attr('href'), strTitle, strParam).focus();
};
$(document).ready(function ($) {
$('.xxx').on('click', function (e) {
$(this).customerPopup(e);
});
});
}(jQuery));
//# sourceURL=pen.js
</script>
<a class="xxx" href="https://www.google.com" target="_blank">
test
</a>
方法。尝试使用insert
方法将数据插入数据库。
create
答案 1 :(得分:0)