及时更改
//文章管理(未发布/已发布)
$(document).on('click','.chang',function () {
var state = $(this).text();
var id = $(this).parents('tr').attr('id');
// console.log(id);
if(state=="已发布"){
$.get(
"chang",
{
id:id,
state:"未发布"
},
function (data) {
history.go(0);
}
);
}else {
$.get(
"chang",
{
id:id,
state:"已发布"
},
function (data) {
history.go(0);
}
);
}
})
//文章管理(未发布/已发布)
public function chang(Request $request){
$state = $request->all();
$model = new Article();
$res = $model->state($state);
return $res;
}
//文章管理(未发布/已发布)
public function state($state){
$tt = [
'uptime'=>date("Y-m-d H:i:s",time()),
'state'=>$state['state']
];
$res = Article::where('id',$state['id'])->update($tt);
return $res;
}