public function save() { if (!$this->validate()) { return false; } $model = new Cate(); $model->setAttributes($this->getAttributes()); !$model->pid && ($model->pid = 0); if (!$model->save()) { $this->addErrors($model->getErrors()); return false; } return true; }
public function edit($id) { $data["_title"] = array("top" => "編輯分類", "main" => "Home", "sub" => "cate"); $data["active"] = "cates"; $data["post"] = Cate::find($id); return View::make('admin.categories.edit', $data); }
public function edit($id) { $data["_title"] = array("top" => "編輯最新消息", "main" => "Home", "sub" => "post"); $data["active"] = "news"; $data["post"] = Post::find($id); $data["cates"] = Cate::where('type', '最新消息')->get()->toArray(); return View::make('admin.posts.edit', $data); }
function index() { $this->layout = 'layout/page'; if (!($id = $this->get('id'))) { throw new HttpException(404); } if (!($content = Content::model()->findByPk($id))) { throw new HttpException(404); } if (!($cate = Cate::model()->findByPk($content->cid))) { throw new HttpException(404); } $this->render('index', array('content' => $content, 'cate' => $cate)); }
function delete() { if (!($id = $this->get('id', 0))) { throw new MHttpException(404); } if (!($model = Cate::model()->findByPk($id))) { throw new MHttpException(404); } if ($model->delete()) { $this->renderCode(0, ''); } else { $this->renderCode(1, 'fail to delete'); } }
function aliasList($cateAlias = null, $contentAlias = null, $limit = 10) { $pagination = new MPagination(); $pagination->setPageSize($limit); $pagination->setCurrentPage(0); if (is_null($cateAlias)) { return Content::model()->findAll('delete_time is null ', array(), $pagination, ' content_id desc '); } if (!($cate = Cate::model()->find('alias = ?', array($cateAlias)))) { return; } if (is_null($contentAlias)) { return Content::model()->findAll('cid = :cid and delete_time is null ', array(':cid' => $cate->cid), $pagination, ' content_id desc '); } return Content::model()->findAll('alias = :alias and cid = :cid ', array(':alias' => $contentAlias, ':cid' => $cate->cid), $pagination, ' content_id desc '); }
protected function fetchData() { $pagination = $this->getPagination(); $sqlOrder = $this->getOrderBy('cid desc'); $sqlFilter = $this->getFilter(); $sql = 'select * from ' . Cate::table() . ' where delete_time is null and ' . $sqlFilter . ' ' . $sqlOrder . ' limit ' . $pagination->getOffset() . ', ' . $pagination->getLimit() . ' '; $list = Cate::getPrepare($sql)->findAll(array()); foreach ($list as $key => $one) { $one['primaryKey'] = "{$one['cid']}"; $list[$key] = $one; } return $list; }
Route::get('/mailcontents', "MailcontentController@index"); Route::get('/delmailcontents/{id}', "MailcontentController@del"); Route::get('/mailcontents/create', "MailcontentController@create"); Route::get('/mailcontent/{id}', "MailcontentController@edit"); Route::post('/mailcontentsStore', "MailcontentController@store"); Route::post('/mailcontentsUpdate', "MailcontentController@update"); //CategoryController Route::get('/delCategory/{id}', "CategoryController@delCategory"); Route::get('/categories', "CategoryController@index"); Route::get('/categories/create', "CategoryController@create"); Route::get('/category/{id}', "CategoryController@edit"); Route::post('/categoryStore', "CategoryController@categoryStore"); Route::post('/categoryUpdate', "CategoryController@categoryUpdate"); Route::get('/delCate', function () { $id = Input::get("id"); Cate::find($id)->delete(); }); }); Route::post('/delRateImage', function () { // print_r(Input::get() ); $rate = Rate::where("id", Input::get("id"))->update(array("image" => '')); if (Input::get("id") > 0) { return 1; } else { return 0; } // return View::make("frontend.hotcase"); }); // App::missing(function($exception) // { //
/** * Remove the specified resource from storage. * * @param int $id * @return Response * articles/id/delete 自定义路由 */ public function destroy($id) { //删除文章标签[真实删除] // Tag::where('aid',$id)->delete(); //检查假删权限【文章uid为登录用户id,并且文章有分类cid!=0】 $obj = Article::find($id); if ($obj->cid == 0 || $obj->uid != Auth::id()) { return Redirect::route('articles.index')->with('error', '不被允许的非法操作!'); } //文章分类总数减1 $cid = Article::find($id)->cid; Cate::where('id', $cid)->decrement('count'); //更改文章分类和状态 Article::where('id', $id)->update(array('cid' => 0, 'status' => 0)); return Redirect::route('articles.index')->with('message', '删除成功!'); }
/** * @return Cate */ static function getNewsCate() { return Cate::model()->find('alias = ?', arrary('news')); }
function beforeAction($action) { $this->cate = Cate::model()->findByPk($this->get('cid')); return parent::beforeAction($action); }
</div> <div class="project_box2"> <a href="hhotcase"><img src="img/bt1.png"/></a> </div> </div> </div> <div class="news"> <div class="news_box"> <div class="word_t"> <img src="img/tt2.png"/> </div> <div class="Group"> <?php $news = Post::all(); $cates = Cate::all(); $cate_array = array(); foreach ($cates as $cate) { $cate_array[$cate->id] = $cate->name; } ?> @foreach($news as $new) <?php $dd = explode(" ", $new->created_at); ?> <a href="/newsInfo?id={{$new->id}}"> <p>{{$dd[0]}}<span>|</span><span class="projectNews">{{isset($cate_array[$new->category_id])?$cate_array[$new->category_id]:''}}</span><span>|</span><span>{{$new->name}}</span></p> </a> @endforeach </div>
function medic() { $cate = Cate::model()->find('alias = ?', array('medic')); $this->render('content', array('cate' => $cate)); }
/** * @分类文章列表 */ public function cate($cid) { try { $cid = intval($cid); } catch (Exception $e) { echo 'error request!'; exit; } $curCate = Cate::find($cid); //检查分类合法性 if (!is_object($curCate)) { return Response::make('cate not exist', 404); } //当前用户id; $uid = $curCate->uid; //根据uid查找用户信息 $user = User::find($uid); //根据关联模型查找当前用户所有分类 $cates = $user->getCate; //查找用户当前分类下的文章列表,分页显示 $articles = Article::where('cid', $cid)->where('uid', $uid)->where('status', 1)->paginate(2); //户当前分类下的文章总数 $count = Article::where('cid', $cid)->where('uid', $uid)->where('status', 1)->count(); //查找最新文章 $recoment = Article::where('uid', $uid)->where('status', 1)->orderBy('updated_at')->take(5)->get(); return View::make('blog.cate', compact('articles'))->with('user', $user)->with('cates', $cates)->with('curCate', $curCate->name)->with('count', $count)->with('recoment', $recoment); }
/** * @destroy */ public function destroy($id) { //权限检查,检查是否非法编辑,分类所有者是登录用户 $cate = Cate::find($id); $uid = $cate->uid; //获取uid if ($uid != Auth::id()) { return Redirect::to('user/login'); } //删除分类 //Cate::find($id)->delete();//按实例删除 Cate::destroy($id); //按住键删除 //修改改分类所属文章状态为0,修改分类为默认值0【可选操作】 Article::where('cid', $id)->update(array('cid' => 0, 'status' => 0)); return Redirect::route('cate.index')->with('message', '分类删除成功!'); }
public function typeStore() { $all = Input::all(); $rate_id = $all["rate_id"]; $type_id = $all["type"]; $name = $all["name"]; unset($all["_token"]); // print_r($all); // $update_data=array('name' => $name,'type' => $type); if (!empty($name)) { Cate::create($all); } return Redirect::to('rate/details_list/' . $rate_id)->withInput()->with('success', '新增成功'); }
<?php $cates = Cate::where('type', "工程進度")->whereNotIn('name', array('圖面下載'))->get(); $cates_array = array(); $cates_not = array(); foreach ($cates as $cate) { $cates_array[$cate->id] = $cate->name; $cates_not[$cate->id] = $cate->id; } $id = Input::get("id"); $rate = Rate::find($id); $dd1 = explode(" ", $rate->created_at); $dd = explode("-", $dd1[0]); $category_id = Input::get("category_id"); if (!empty($id)) { // print_r($cates_not); $pics = DB::table("rate_pics")->where('rate_id', $id)->whereIn('category_id', $cates_not)->get(); } else { $pics = DB::table("rate_pics")->first(); } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>工程進度</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="css/css.css"> <link rel="stylesheet" type="text/css" href="css/process.css">
public function save() { $this->cateid = Cate::getNewsCate(); return parent::save(); }