public function run() { for ($i = 1; $i <= 130; $i++) { Extend::create(array('id' => "{$i}", 'star' => '4', 'up' => '0', 'down' => '0', 'top' => '0')); } }
public function delete($id = 0) { if (is_array(Input::get('ids'))) { $id = Input::get('ids'); } $ok = Comment::destroy($id); if ($ok) { $ok_extend = Extend::destroy($id); if ($ok_extend) { return Redirect::to('msg')->withInput()->with('jump_sec', 3)->with('message', "删除成功!"); } else { return Redirect::to('msg')->withInput()->with('jump_sec', 120)->with('message', "扩展数据 删除失败! 请手工修复数据"); } } else { return Redirect::to('msg')->withInput()->with('jump_sec', 3)->with('message', "删除失败!"); } }
protected function _avg_like_star($project_id, $page_id) { $ex = explode(':', $page_id); if (is_array($ex)) { $page_id_pre = $ex[0]; $star[$page_id] = Extend::join('comments', 'comments.id', '=', 'comment_extend.id')->whereRaw("`project_id` = '{$project_id}' and `page_id` like '{$page_id_pre}:%' and `status` = '1' and `star` > 0")->avg('comment_extend.star'); } else { $star[$page_id] = Extend::join('comments', 'comments.id', '=', 'comment_extend.id')->whereRaw("`project_id` = '{$project_id}' and `page_id` like '{$page_id}:%' and `status` = '1' and `star` > 0")->avg('comment_extend.star'); } return $star; }