Ejemplo n.º 1
0
 function countLinks($categoryName)
 {
     App::import('Model', 'Link');
     $link = new Link();
     $settings = array('conditions' => array('LinkCategory.name' => $categoryName));
     return $link->find('count', $settings);
 }
Ejemplo n.º 2
0
 public function post_edit()
 {
     $link = Link::find(Input::get('id'));
     $link->name = Input::get('name');
     $product->short_description = Input::get('short_description');
     $product->slug = Str::slug(Input::get('name'), '_');
     $product->save();
     return Redirect::to_action('admin.products@view', array($product->id))->with('flash', true)->with('flash_type', 'success')->with('flash_msg', 'Product updated successfully.');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $this->link = Link::find($id);
     $this->link->fill(Input::all());
     if (!$this->link->valid()) {
         return Redirect::back()->withInput()->with('errors', $this->link->errors);
     } else {
         $this->link->update();
         return Redirect::route('projects.index');
     }
 }
Ejemplo n.º 4
0
 /**
  * [link_update description]
  * @param  [type] $slug [description]
  * @return [type]       [description]
  */
 public function link_update($slug)
 {
     if (IS_POST) {
         $data = ['name' => I('post.name'), 'url' => I('post.url'), 'is_look' => I('post.is_look')];
         Link::where('id', '=', $slug)->update($data);
         View::success('修改成功');
         die;
     }
     $link = Link::find($slug)->toArray();
     $this->smarty->assign('link', $link);
     $this->smarty->assign('title', '修改友情链接_ISisWeb中文网后台管理_ISirPHPFramework');
     $this->smarty->display('Admin/System/update_link.html');
     // $this->view = View::make('/Admin/System/update_link')
     // 				->with('link',$link)
     // 				->with('title','修改友情链接_ISirPHP Framework');
 }
Ejemplo n.º 5
0
 /**
  * Delete Link
  *
  * @return Response
  */
 public function postDelete()
 {
     if (!\Auth::check()) {
         return \Response::json(array('error' => array('code' => 'NOT-AUTH', 'http_code' => '403', 'message' => 'Forbidden')), 403);
     }
     if (!\Input::has("linkid")) {
         return \Response::json(array('error' => array('code' => 'MISSING-PARAMETERS', 'http_code' => '400', 'message' => 'Bad Request')), 400);
     }
     $linkID = \Input::get("linkid");
     $shortenedLink = \Link::find($linkID);
     if (\Auth::user()->id != $shortenedLink->user_id) {
         return \Response::json(array('error' => array('code' => 'NOT-AUTH', 'http_code' => '403', 'message' => 'Forbidden')), 403);
     }
     $shortenedLink->delete();
     if (\Auth::user()->quota_used - 1 >= 0) {
         \Auth::user()->quota_used -= 1;
         \Auth::user()->save();
     }
     return \Response::json(array('ok' => array('code' => 'LINK-DELETED', 'http_code' => '200', 'message' => 'OK')), 200);
 }
Ejemplo n.º 6
0
 public function getCategoryLink($id)
 {
     $link = Link::find($id);
     if (isset($link->gov_id)) {
         $this->breadcrumbs->push('หมวดหมู่', URL::to('/categories'));
         $this->breadcrumbs->push($link->MiddleCategories->name, URL::to('/category/' . $link->MiddleCategories->id . '/new'));
         $this->breadcrumbs->push($link->name, URL::to('/category/link/' . $link->Gov->id . '/show'));
         $this->breadcrumbs->generate();
         return View::make('home.category_link')->with('link', $link);
     } else {
         App::abort(404);
     }
 }
Ejemplo n.º 7
0
 public function updateLink()
 {
     $id = Input::get('id');
     $fieldname = Input::get('field');
     $value = Input::get('value');
     $link = Link::find($id);
     $link->{$fieldname} = $value;
     $link->save();
     return $this->success(null, null);
 }
Ejemplo n.º 8
0
 public function deleteLink()
 {
     $link_id = Input::get('link_id');
     $link = Link::find($link_id);
     if (!$link->delete()) {
         return Response::json(array('errCode' => '1', 'message' => '删除失败!'));
     }
     return Response::json(array('errCode' => 0, 'message' => '删除成功!'));
 }
Ejemplo n.º 9
0
 public function getShowLink($id)
 {
     $link = Link::find($id);
     if (isset($link->gov_id)) {
         $gov = Gov::findOrFail($link->gov_id);
         $gov = $gov->name;
     } else {
         $gov = "ไม่ได้กำหนดหน่วยงาน";
     }
     $columns = Schema::getColumnListing('links');
     return View::make('admin.show_link')->with('link', $link)->with('columns', $columns)->with('govName', $gov);
 }