api surat views increment

This commit is contained in:
merdan 2021-05-12 15:05:27 +05:00
parent 802aaea75d
commit cd8ac64165
1 changed files with 6 additions and 2 deletions

View File

@ -45,8 +45,12 @@ class postsController extends Controller
->where('post_id', $post->getKey()); ->where('post_id', $post->getKey());
if ($obj->count() > 0) { if ($obj->count() > 0) {
$obj = $obj->first(); $row = $obj->first();
$post['views'] = $obj->views;
$views = ++$row->views;
$obj->update(['views' => $views]);
$post['views'] = $row->views;
} }
} }
if ($post){ if ($post){