Ejemplo n.º 1
0
 public function boot()
 {
     $boots = Node::whereHas('parents', function ($q) {
         $q->where('node_parent_id', '=', '0');
     })->get();
     return $boots;
 }
Ejemplo n.º 2
0
 public function getValues($values)
 {
     foreach ($values as $languageId => &$value) {
         $value = Node::find($value);
     }
     return $values;
 }
Ejemplo n.º 3
0
 public function show($id)
 {
     $node = Node::findOrFail($id);
     $filter = $this->topic->present()->getTopicFilter();
     $topics = $this->topic->getNodeTopicsWithFilter($filter, $id);
     return view('topics.index', compact('topics', 'node'));
 }
Ejemplo n.º 4
0
 public function postPost(Request $request)
 {
     $input = $request->all();
     $rules = ['title' => ['max:20', 'required'], 'content' => ['min:10', 'required']];
     $validator = Validator::make($input, $rules);
     $returnInf = [];
     if ($validator->fails()) {
         $messages = $validator->messages();
         foreach ($array_dot($messages->toArray) as $value) {
             array_push($returnInf, $value);
         }
         Session::flash('operationResult', 'am-alert-warning');
         Session::flash('returnInf', $returnInf);
         return redirect()->back()->withInput(Request::flash());
     } else {
         $article = Article::create(['title' => $input['title'], 'content' => Common::encodeTopicContent($input['content']), 'node_id' => $input['node_id'], 'user_id' => $input['user_id']]);
         if ($article->id > 0) {
             array_push($returnInf, '发帖成功');
             Session::flash('operationResult', 'am-alert-success');
             Node::find($input['node_id'])->increment('article_count');
             User::find($input['user_id'])->increment('article_count');
         } else {
             array_push($returnInf, '我们的数据库出问题啦,请稍后再试=。=');
             Session::flash('operationResult', 'am-alert-warning');
         }
     }
     Session::flash('returnInf', $returnInf);
     return redirect()->back();
 }
 /**
  * The home page Ok
  */
 public function home()
 {
     $topics = $this->topic->getTopicsWithFilter('excellent');
     $nodes = \App\Node::allLevelUp();
     //return $nodes;
     return view('pages.home', compact('topics', 'nodes'));
 }
Ejemplo n.º 6
0
 /**
  * Display the content of the page
  *
  * @param $query
  * @return \Illuminate\View\View
  */
 public function display($query)
 {
     $title = 'TestView';
     $page = "";
     $arr = explode('/', $query);
     // \App\Page::find(4)->content->find(5)->element->module->name
     $heading = \App\Node::findBySlug('header');
     //        dd(\App\Node::findBySlug($arr[0])->content);
     // test
     $content = \App\Node::active()->findBySlug($arr[0])->content;
     foreach ($content as $item) {
         // get the module Name of
         //            $module = \App\Module::findOrFail($p->module_id);
         // resolve the Module Name out of the IOC Container and render the content partiall
         //            $content .= App::make('module:' . $module->name)->render($p->content_id);
         //            foreach ($item->content as $content)
         //            {
         //Todo check if Module is Active and Content is Active
         $module = $item->element->module->name;
         if ($module != 'Heading') {
             continue;
         }
         // resolve the Module out of the IOC Container and render the partial
         $page .= App::make('module:' . strtolower($module))->render($item->element->row);
         //            }
     }
     return view('layout.master', compact('title', 'page'));
 }
Ejemplo n.º 7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //$nodes = \App\Node::where('poll_enabled', 'Y')->get();
     $nodes = \App\Node::all();
     foreach ($nodes as $node) {
         unset($exec_out1);
         exec('/usr/sbin/fping -e ' . $node->ip_address . ' 2>/dev/null', $exec_out1, $exec_ret1);
         if ($exec_ret1 == 0) {
             // ping ok
             $ping_success = 100;
         } else {
             // ping fail
             $ping_success = 0;
         }
         print $node->ip_address . ' = ' . $ping_success . '%' . PHP_EOL;
         $u_node = \App\Node::find($node->id);
         $u_node->ping_success = $ping_success;
         $u_node->save();
         $ping = new \App\Ping();
         $ping->node_id = $node->id;
         $ping->success = $ping_success;
         $ping->timestamp = \Carbon\Carbon::now();
         $ping->save();
     }
 }
Ejemplo n.º 8
0
 /**
  * api/v1/{category}/{slug}/reviews
  * Get reviews for a node.
  *
  * @param  int  $id
  * @return Response
  */
 public static function reviews($category, $slug)
 {
     $node = Node::where('category', $category)->where('slug', $slug)->first();
     $filter = isset($_GET['filter']) ? $_GET['filter'] : null;
     $skip = isset($_GET['skip']) ? $_GET['skip'] : 0;
     $take = isset($_GET['take']) ? $_GET['take'] : 10;
     switch ($filter) {
         case 'newest':
             $reviews = DB::collection('reviews')->where('node.reference', $node->_id)->orderBy('created_at', 'desc')->skip($skip)->take($take)->get();
             break;
         case 'oldest':
             $reviews = DB::collection('reviews')->where('node.reference', $node->_id)->orderBy('created_at', 'asc')->skip($skip)->take($take)->get();
             break;
         case 'highest':
             $reviews = DB::collection('reviews')->where('node.reference', $node->_id)->orderBy('score', 'desc')->skip($skip)->take($take)->get();
             break;
         case 'lowest':
             $reviews = DB::collection('reviews')->where('node.reference', $node->_id)->orderBy('score', 'asc')->skip($skip)->take($take)->get();
             break;
         default:
             $reviews = DB::collection('reviews')->where('node.reference', $node->_id)->orderBy('created_at', 'desc')->skip($skip)->take($take)->get();
             break;
     }
     return response()->json($reviews);
 }
Ejemplo n.º 9
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Inception
     $node = new Node();
     $node->category = 'films';
     $node->themoviedb_id = 27205;
     $node->imdb_id = 'tt1375666';
     $node->title = 'Inception';
     $node->slug = 'inception';
     $node->director = "Christopher Nolan";
     $node->cover = "50634dbcbe4617f17bb159d0.jpg";
     $node->poster = "50634dbcbe4617f17bb159d0.jpg";
     $node->backgroundPosition = "50";
     $node->year = 2010;
     $node->synopsis = "A thief who steals corporate secrets through use of dream-sharing technology is given the inverse task of planting an idea into the mind of a CEO.";
     $node->save();
 }
Ejemplo n.º 10
0
 public static function add($lat, $lng, $radius, $id)
 {
     $model = Node::firstByAttributes(array('circle_id' => $id));
     if (!$model) {
         $model = new Node();
     }
     $model->latitude = $lat;
     $model->longitude = $lng;
     $model->radius = $radius;
     $model->circle_id = $id;
     $model->weight = 1;
     $model->path_id = 1;
     if ($model->save()) {
         return TRUE;
     }
     return FALSE;
 }
 public function show($id, urlRequest $request)
 {
     $node = Node::findOrFail($id);
     $search = $request->query('q');
     $filter = $this->topic->present()->getTopicFilter();
     $topics = $this->topic->getNodeTopicsWithFilter($filter, $id)->search($search)->paginate(20);
     $this->setupLayout();
     return view('topics.index', compact('topics', 'node'));
 }
Ejemplo n.º 12
0
 public function edit($id)
 {
     $topic = Topic::findOrFail($id);
     $this->authorOrAdminPermissioinRequire($topic->user_id);
     $nodes = Node::allLevelUp();
     $node = $topic->node;
     $topic->body = $topic->body_original;
     return view('topics.create_edit', compact('topic', 'nodes', 'node'));
 }
Ejemplo n.º 13
0
 public function run()
 {
     $faker = Faker::create();
     $users = User::lists('id')->all();
     $nodes = Node::lists('id')->all();
     foreach (range(1, 50) as $index) {
         factory(App\Topic::class)->create(['user_id' => $faker->randomElement($users), 'node_id' => $faker->randomElement($nodes)]);
         factory(App\Topic::class, 'excellent')->create(['user_id' => $faker->randomElement($users), 'node_id' => $faker->randomElement($nodes)]);
     }
 }
 public function getGenerateManual($role_name = NULL)
 {
     $permission_array = \Login::get_role_permissions($role_name);
     $array = ['role_name' => $role_name];
     $array['title'] = 'Manual de Administrador';
     $array['site'] = \App\Site::find(1);
     $array['nodes'] = \App\Node::whereNull('parent_id')->whereIn('permission', $permission_array)->with('fields', 'children.fields', 'children.children.fields')->get();
     $pdf = \PDF::loadView('pdf.manual', $array);
     $header = \View::make('pdf.header', $array);
     return $pdf->setPaper('letter')->setOption('header-html', $header->render())->stream(trans('admin.manual') . '_' . date('Y-m-d') . '.pdf');
 }
Ejemplo n.º 15
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $mynodes = \App\Task::where('user_id', \Auth::user()->id)->count();
     $myonlinenodes = \App\Node::join('tasks', 'tasks.node_id', '=', 'nodes.id')->where('tasks.user_id', \Auth::user()->id)->join('nodestats', 'nodestats.node_id', '=', 'nodes.id')->where('nodestats.isonline', 0)->count();
     $procent = $mynodes > 0 ? $myonlinenodes / $mynodes * 100 : 0;
     $myclients = \App\Nodestat::join('tasks', 'tasks.node_id', '=', 'nodestats.id')->where('tasks.user_id', \Auth::user()->id)->where('clientcount', '>', 0)->get();
     $myclients = $myclients->sum(function ($node) {
         return $node->clientcount;
     });
     return view('home/index')->with('mynodes', $mynodes)->with('onlineprocent', $procent)->with('myclients', $myclients);
 }
Ejemplo n.º 16
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $user = factory(App\User::class)->create(['name' => 'p', 'email' => $faker->email(), 'password' => bcrypt('test')]);
     //$node = factory(App\Node::class)->create();
     //factory(App\Node::class, 100)->create();
     //$nodestatus = factory(App\Nodestat::class, 50)->create(['node_id' => $node->id]);
     $task = factory(App\Task::class)->create(['user_id' => $user->id, 'node_id' => \App\Node::all()->random(1)->id]);
     $task = factory(App\Task::class)->create(['user_id' => $user->id, 'node_id' => \App\Node::all()->random(1)->id]);
     $task = factory(App\Task::class)->create(['user_id' => $user->id, 'node_id' => \App\Node::all()->random(1)->id]);
     Model::reguard();
 }
Ejemplo n.º 17
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $nodes = \App\Node::where('ping_success', '100')->where('snmp_success', '100')->get();
     $counter = 0;
     foreach ($nodes as $node) {
         print "{$counter} {$node->ip_address} = ";
         $discover_result = \App\Http\Controllers\NodesController::execDiscover($node->id);
         print $discover_result . PHP_EOL;
         $counter++;
     }
 }
Ejemplo n.º 18
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     print \Carbon\Carbon::now() . ' Start snmpPoller...' . "\n";
     $nodes = \App\Node::where('ping_method', 'ping')->where('ping_params', '')->where('ping_success', 100)->get();
     $start_timestamp = time();
     $counter = 0;
     foreach ($nodes as $node) {
         // try v2c
         $snmp = new \App\Lnms\Snmp($node->ip_address, $node->snmp_comm_ro, '2c');
         $snmp->setOptions('-r 1 -t 1');
         $get_result = $snmp->get(OID_sysUpTime);
         if ($get_result) {
             $snmp_version = 2;
         } else {
             // try v1
             $snmp = new \App\Lnms\Snmp($node->ip_address, $node->snmp_comm_ro);
             $snmp->setOptions('-r 1 -t 1');
             $get_result = $snmp->get(OID_sysUpTime);
             $snmp_version = 1;
         }
         if ($get_result) {
             // snmp ok
             $snmp_success = 100;
             $get_sysUpTime = $get_result[OID_sysUpTime];
             // get sysObjectID
             $get_result2 = $snmp->get([OID_sysObjectID, OID_sysName]);
             $get_sysObjectID = $get_result2[OID_sysObjectID];
             $get_sysName = $get_result2[OID_sysName];
         } else {
             // snmp fail
             $snmp_version = 0;
             $snmp_success = 0;
             $get_sysUpTime = 0;
             $get_sysObjectID = '';
             $get_sysName = '';
         }
         $current_timestamp = time();
         $diff_timestamp = $current_timestamp - $start_timestamp;
         print \Carbon\Carbon::now() . " {$counter} ({$diff_timestamp} s.) - {$node->ip_address} {$node->snmp_comm_ro} = (v{$snmp_version}) {$snmp_success} {$get_sysUpTime} = {$get_sysObjectID} {$get_sysName}\n";
         $u_node = \App\Node::find($node->id);
         $u_node->snmp_version = $snmp_version;
         $u_node->snmp_success = $snmp_success;
         $u_node->snmp_updated = \Carbon\Carbon::now();
         $u_node->sysObjectID = $get_sysObjectID;
         $u_node->sysName = $get_sysName;
         $u_node->sysUpTime = $get_sysUpTime;
         $u_node->save();
         $counter++;
     }
     print \Carbon\Carbon::now() . ' Stop snmpPoller...' . "\n";
 }
Ejemplo n.º 19
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $author = User::where('name', '=', 'Jamie Shepherd')->first();
     $node = Node::where('category', '=', 'films')->where('title', '=', 'Inception')->first();
     $review = new Review();
     $review->author = array('reference' => $author->_id, 'name' => $author->name, 'gravatar' => md5(strtolower(trim($author->email))));
     $review->node = array('reference' => $node->_id, 'title' => $node->title);
     $review->score = 7.9;
     $review->review = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.';
     $review->thumbs = 0;
     $review->save();
     $node->avg = number_format(round(Review::where('node.reference', $node->_id)->avg('score'), 1), 1);
     $node->increment('reviewCount');
     $node->save();
 }
Ejemplo n.º 20
0
 private function chainUpdate($node)
 {
     if (count($node->children) > 0) {
         $ids = [];
         foreach ($node->children as $n) {
             array_push($ids, $n->id);
         }
         $dpt = getDepth($node->id);
         $data = ['parent_id' => $node->id, 'depth' => $dpt['depth'], 'thread' => $dpt['thread']];
         \App\Node::whereIn('id', $ids)->update($data);
         foreach ($node->children as $n) {
             if (count($n->children) > 0) {
                 $this->chainUpdate($n);
             }
         }
     }
 }
 public function initializeNodes()
 {
     DB::table('nodes')->truncate();
     $node_array = ['PHP' => ['php' => ['slug' => 'php', 'description' => 'PHP(PHP: Hypertext Preprocessor的缩写,中文名:“PHP:超文本预处理器”)是一种通用开源脚本语言。'], 'Laravel' => ['slug' => 'laravel', 'description' => 'Laravel是一套简洁、优雅的PHP Web开发框架(PHP Web Framework)。它可以让你从面条一样杂乱的代码中解脱出来;它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁、富于表达力。'], 'Composer & Packagist' => ['slug' => 'composer-and-packagist', 'description' => 'Composer[1]是PHP中用来管理依赖(dependency)关系的工具。你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer会帮你安装这些依赖的库文件。'], '重构' => ['slug' => 'refactoring', 'description' => '由于软件发展本身不可能是完美的,因此改进的过程是持续且必然的,重构的方式将作为改善软件设计的一种手段和方式,更加地拥有现实意义。'], '设计模式' => ['slug' => 'design-pattern', 'description' => '设计模式(Design pattern)是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了可重用代码、让代码更容易被他人理解、保证代码可靠性。'], 'Testing' => ['slug' => 'testing', 'description' => '软件测试(英语:software testing),描述一种用来促进鉴定软件的正确性、完整性、安全性和质量的过程。'], '部署' => ['slug' => 'deployment', 'description' => ''], '开源项目' => ['slug' => 'opensource-project', 'description' => '']], 'Web 开发' => ['MySQL' => ['slug' => 'mysql', 'description' => 'MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司。'], 'Database' => ['slug' => 'database', 'description' => '数据库(Database)是按照数据结构来组织、存储和管理数据的仓库'], 'Git' => ['slug' => 'git', 'description' => 'Git是一个开源的分布式版本控制系统,用以有效、高速的处理从很小到非常大的项目版本管理。'], 'Linux' => ['slug' => 'linux', 'description' => 'Linux是一种自由和开放源码的类Unix操作系统,存在着许多不同的Linux版本,但它们都使用了Linux内核。'], 'WebServer' => ['slug' => 'web-server', 'description' => 'WEB服务器也称为WWW(WORLD WIDE WEB)服务器,主要功能是提供网上信息浏览服务。常见的有 Nginx, Apache..'], '算法' => ['slug' => 'algrithm', 'description' => '算法(Algorithm)是指解题方案的准确而完整的描述,是一系列解决问题的清晰指令,算法代表着用系统的方法描述解决问题的策略机制。'], '运维' => ['slug' => 'operations', 'description' => ''], '安全' => ['slug' => 'security', 'description' => ''], '云服务' => ['slug' => 'cloud-service', 'description' => '云服务开发这一概念包含几种不同的开发类型 - 软件即服务(SaaS), 平台即服务(PaaS), Web服务, 按需(on—demand)计算']], 'Mobile' => ['iPhone' => ['slug' => 'iphone-development', 'description' => 'iPhone 开发'], 'Android' => ['slug' => 'android-development', 'description' => 'Android 开发']], 'Languages' => ['JavaScript' => ['slug' => 'javascript', 'description' => 'JavaScript是一种基于对象和事件驱动并具有相对安全性的客户端脚本语言。'], 'Ruby' => ['slug' => 'ruby', 'description' => 'Ruby,一种为简单快捷的面向对象编程(面向对象程序设计)而创的脚本语言'], 'Python' => ['slug' => 'python', 'description' => 'Python, 是一种面向对象、直译式计算机程序设计语言'], 'GoLang' => ['slug' => 'golang', 'description' => 'Go语言是谷歌推出的一种全新的编程语言,可以在不损失应用程序性能的情况下降低代码的复杂性。'], 'Erlang' => ['slug' => 'erlang', 'description' => 'Erlang是一种通用的面向并发的编程语言,它由瑞典电信设备制造商爱立信所辖的CS-Lab开发,目的是创造一种可以应对大规模并发活动的编程语言和运行环境。']], '社区' => ['公告' => ['slug' => 'announcement', 'description' => ''], '反馈' => ['slug' => 'feedback', 'description' => '对于社区的优化或者 bug report , 可以在此节点下提'], '社区开发' => ['slug' => 'community-development', 'description' => '构建此社区软件的开发讨论节点'], '线下聚会' => ['slug' => 'gathering', 'description' => '']], '分享' => ['健康' => ['slug' => 'health', 'description' => ''], '工具' => ['slug' => 'toolings', 'description' => '使用工具, 是人类文明的标志'], '其他' => ['slug' => 'other-share', 'description' => '抱歉, 如果你分享的话题不属于其他节点的话, 只能选择这里咯. '], '书籍' => ['slug' => 'book-share', 'description' => '书籍是知识载体, 让我们一起站在巨人的肩膀上. '], '求职' => ['slug' => 'request-a-job', 'description' => '介绍下你自己, 让大家帮你找到一份好的工作'], '招聘' => ['slug' => 'hire', 'description' => '这里有高质量的 PHPer, 记得认真填写你的需求, 薪资待遇是必须写的哦.'], '创业' => ['slug' => 'start-up', 'description' => ''], '移民' => ['slug' => 'immigration', 'description' => '']]];
     $top_nodes = array();
     foreach ($node_array as $key => $value) {
         $top_nodes[] = ['name' => $key];
     }
     DB::table('nodes')->insert($top_nodes);
     $nodes = array();
     foreach ($node_array as $key => $value) {
         $top_node = Node::where('name', '=', $key)->first();
         foreach ($value as $snode => $svalue) {
             $nodes[] = ['parent_node' => $top_node->id, 'name' => $snode, 'slug' => $svalue['slug'], 'description' => $svalue['description']];
         }
     }
     DB::table('nodes')->insert($nodes);
 }
Ejemplo n.º 22
0
 public function getnode($id = 0)
 {
     if (!$id) {
         throw new \Exception('Node ID is undefined');
     }
     $current_node = Node::find((int) $id);
     $nodes_array = [];
     if ($current_node) {
         $getColumn = (new Node())->getAllColumnsNames();
         //var_dump($getColumn);
         $fieldsValue = $current_node->toArray();
         $nodes_array = array_map(function ($field) use($fieldsValue) {
             $field['value'] = $fieldsValue[$field['name']];
             return $field;
         }, $getColumn);
     }
     return response()->json($nodes_array);
 }
Ejemplo n.º 23
0
 public static function allLevelUp()
 {
     return Cache::remember(self::CACHE_KEY, self::CACHE_MINUTES, function () {
         $nodes = Node::all();
         $result = array();
         foreach ($nodes as $key => $node) {
             if ($node->parent_node == null) {
                 $result['top'][] = $node;
                 foreach ($nodes as $skey => $snode) {
                     if ($snode->parent_node == $node->id) {
                         $result['second'][$node->id][] = $snode;
                     }
                 }
             }
         }
         return $result;
     });
 }
Ejemplo n.º 24
0
 public function postsList($nodeId = '')
 {
     $nodeIds = DB::table('node_hierarchy')->where('node_parent_id', '=', $nodeId)->lists('node_id');
     $nodeIds = array_merge($nodeIds, [$nodeId]);
     $nodeIds = implode(',', $nodeIds);
     //        if($nodeId==''){
     //            $posts = Post::paginate(10);
     //            $node = '';
     //        }else{
     $posts = Post::whereRaw("node_id in ({$nodeIds})")->orderBy('created_at', 'DESC')->paginate(6);
     $node = Node::find($nodeId);
     //        }
     //dd(response()->json(view('home.post.posts',compact('posts'))->render()));
     if (Request::ajax()) {
         return response()->json(view('home.post.posts', compact('posts'))->render());
     }
     return view('home.post.index', compact('posts', 'node'));
 }
Ejemplo n.º 25
0
 public function saveCircleToDatabase(Request $request)
 {
     $lat = $request->input('lat');
     $lng = $request->input('lng');
     $radius = $request->input('radius');
     $id = $request->input('id');
     $type = $request->input('type');
     if ($type === 'node') {
         $result = Node::add($lat, $lng, $radius, $id);
     } else {
         if ($type == 'poi') {
             $result = Point_of_interest::add($lat, $lng, $radius, $id);
         }
     }
     if ($result) {
         return response()->json(array('status' => 1, 'message' => 'Success'));
     }
     return response()->json(array('status' => 0, 'message' => 'Error !!'));
 }
Ejemplo n.º 26
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $data = json_decode(file_get_contents('http://karte.freifunk-stuttgart.de/json/nodes.json'), true);
     if (count($data) > 0 && isset($data['nodes']) && isset($data['meta']['timestamp'])) {
         foreach ($data['nodes'] as $nodeArr) {
             //find or new node
             $node = \App\Node::firstOrNew(['mac' => $nodeArr['id']]);
             $node->name = $nodeArr['name'];
             $node->save();
             //find or new  nodestats
             $nodestat = \App\Nodestat::firstOrNew(['node_id' => $node->id]);
             $nodestat->isonline = $nodeArr['flags']['online'] == "true" ? 1 : 0;
             $nodestat->clientcount = $nodeArr['clientcount'];
             $nodestat->save();
         }
     } else {
         //TODO mail to admin -> json kaputt
     }
 }
Ejemplo n.º 27
0
 public function getUpdate($type, $act, $id = 0)
 {
     $nodes = \App\Node::top()->where('content_type', $type)->get();
     $article = new Article();
     $flag = 0;
     if ($act != 'add') {
         $flag = 1;
         $article = Article::find($id);
         if ($act == 'delete') {
             $url = \Request::header('Referer');
             $info = ['from' => 'del', 'status' => 'failed'];
             if ($article->delete()) {
                 $info['status'] = 'success';
                 j4flash($info);
                 return redirect($url);
             } else {
                 j4flash($info);
                 return redirect($url);
             }
         }
     }
     return view('admin.article.update', compact('flag', 'article', 'nodes'));
 }
Ejemplo n.º 28
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function create($category, $slug)
 {
     $node = Node::where('category', $category)->where('slug', $slug)->first();
     $score = 0.0;
     if (Input::get('score') == 10) {
         $score = 10;
     } else {
         $score = Input::get('score');
     }
     // If it's the first review, reward the user
     if (Review::where('node.reference', $node->_id)->count() == 0) {
         Auth::user()->points += 1000;
         Auth::user()->save();
     }
     // Create the review
     $review = new Review();
     $review->node = array('reference' => $node->_id, 'title' => $node->title);
     $review->author = array('reference' => Auth::user()->_id, 'name' => Auth::user()->name, 'gravatar' => md5(strtolower(trim(Auth::user()->email))));
     $review->score = (double) $score;
     $review->review = Input::get('review');
     $review->thumbs = 0;
     $review->spoilers = Input::has('spoilers');
     $review->save();
     if ($review->score < 4) {
         $node->increment('overall_negative');
     } else {
         if ($review->score < 7) {
             $node->increment('overall_mixed');
         } else {
             $node->increment('overall_positive');
         }
     }
     $node->avg = number_format(round(Review::where('node.reference', $node->_id)->avg('score'), 1), 1);
     $node->increment('reviewCount');
     $node->save();
     return back();
 }
Ejemplo n.º 29
0
 /**
  * Update the specified resource in storage.
  *
  * @param string $category
  * @param string $slug
  * @return Response
  */
 public function update($category, $slug)
 {
     $node = Node::where('category', $category)->where('slug', $slug)->first();
     $node->backgroundPosition = Input::get('position');
     $node->save();
     return redirect('/' . $category . '/' . $slug);
 }
Ejemplo n.º 30
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //        Log::info('Dashboard is visited', ['name' => auth()->user()->fullname()]);
     $nodes = \App\Node::allDeleted()->get();
     return view('admin.index', compact('nodes'));
 }