Beispiel #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function post(Request $request, $post)
 {
     $qGetTags = Tags::all();
     $qGetCategories = Categories::where('cID', '!=', 1)->get();
     $qArticle = $post;
     return view('user.show-post', compact('qGetTags', 'qGetCategories', 'qArticle'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $categories = Categories::where('parent_id', '>=', 0)->get();
     $baseUrl = 'http://7xkn9n.com1.z0.glb.clouddn.com/img/';
     $string = file_get_contents(__DIR__ . "/../data/products.json");
     $products = json_decode($string, true);
     $cate_ids = [];
     foreach ($categories as $category) {
         $cate_ids[] = $category->id;
     }
     foreach ($products as $productData) {
         try {
             $name = $productData['meta']['title'];
             $content = '';
             if (isset($productData['content'])) {
                 $content = str_replace('<h2 class="title">百科词条</h2>', '', $productData['content']);
             }
             $klass = $productData['meta']['class']['text'];
             $category = Categories::where('name', $klass)->get();
             $description = substr($content, 0, 100);
             $cid = $faker->randomElement($cate_ids);
             if ($category->count() == 1) {
                 $cid = $category[0]->id;
             }
             $pieces = preg_split("/\\//i", $productData['meta']['image']);
             $product = Product::create(['name' => $name, 'slug' => $name, 'description' => $description, 'keywords' => $klass, 'cover' => $baseUrl . $pieces[count($pieces) - 1], 'category_id' => $cid, 'user_id' => 1]);
             $detailTopic = Topic::create(['title' => $name, 'slug' => $name, 'product_id' => $product->id, 'user_id' => 1, 'keywords' => $name, 'description' => $description, 'content' => $content, 'is_product_detail_topic' => true]);
             $product->detail_topic_id = $detailTopic->id;
             $product->save();
         } catch (Exception $e) {
             throw $e;
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     if ($request->cID) {
         $category = Categories::where("cID", $request->cID)->first();
     } else {
         $category = new Categories();
     }
     $category->cName = $request->cName;
     $category->cDescription = $request->cDes;
     $category->cParentID = $request->categoryParent;
     $category->cIsActive = is_null($request->active) ? 0 : 1;
     $file = Input::file('image');
     if (!is_null($file)) {
         $destinationPath = public_path() . '/assets/images/';
         $fileName = explode(".", $file->getClientOriginalName())[0];
         $fileName = $fileName . rand(1, 9999) . "." . $file->getClientOriginalExtension();
         Input::file('image')->move($destinationPath, $fileName);
         $category->cIcon = $fileName;
         if ($request->cID) {
             //remove file name before
         }
     }
     $category->save();
     return Redirect::action('admin\\category@index');
     /* https://laracasts.com/discuss/channels/general-discussion/laravel-5-image-upload-and-resize?page=1
      *  Link upload and resize image
      */
 }
 public function getForm($id = null)
 {
     $dataAdmin = new PrProviders();
     $modelProviders = new PrTypes();
     $modelCategories = new Categories();
     $listProviders = $modelProviders->where('flagactive', PrTypes::STATE_ACTIVE)->lists('name_type', 'id')->toArray();
     $listProviders = [null => 'Select un tipo'] + $listProviders;
     $listCategories = $modelCategories->where('flagactive', Categories::STATE_ACTIVE)->lists('name_category', 'id')->toArray();
     $listCategories = [null => 'Select una categoria'] + $listCategories;
     if (!is_null($id)) {
         $dataAdmin = PrProviders::find($id);
     }
     return viewc('admin.' . self::NAMEC . '.form', compact('dataAdmin', 'listProviders'), ['listCategories' => $listCategories, 'listCategories' => $listCategories]);
 }
Beispiel #5
0
 public function getForm($id = null, $modulo = null)
 {
     $modelCategories = new Categories();
     $listTypes = PuTypes::whereFlagactive(PuTypes::STATE_ACTIVE)->lists('name_type', 'id')->toArray();
     $listTypes = [null => 'Select un tipo'] + $listTypes;
     $listCategories = $modelCategories->where('flagactive', Categories::STATE_ACTIVE)->lists('name_category', 'id')->toArray();
     $listCategories = [null => 'Select una categoria'] + $listCategories;
     $dataPost = PuAds::find($id);
     if (!is_null($id)) {
         $dataPost = PuAds::find($id);
         $dataPicture = PuPicture::wherePuAdId($id)->first();
         $dataPost->picture = !empty($dataPicture->url) ? "{$dataPost->picture}" : null;
         $dataPost->pr_provider_id = !empty($dataPost->pr_provider_id) ? "{$dataPost->pr_provider_id}" : 0;
     }
     return viewc('admin.' . self::NAMEC . '.form', compact('dataPost', 'modulo'), ['listCategories' => $listCategories, 'listTypes' => $listTypes]);
 }
 public function crawler(Request $request)
 {
     $this->allLinks = array();
     if ($request->server('REQUEST_METHOD') == "POST") {
         $domain = strpos($request->domainURL, "http://") !== false ? $request->domainURL : "http://" . $request->domainURL;
         $this->domain = $domain;
         $this->count = $request->limitPages;
         $this->index_current = 0;
         $this->limit_page = $request->limitPages;
         $this->allLinks[0] = array("page" => $domain, "status" => "", "mark" => "");
         $this->find_character = $request->checkCharacter;
         $this->spider($domain);
     }
     $allLinks = $this->allLinks;
     $qGetTags = Tags::all();
     $qGetCategories = Categories::where('cID', '!=', 1)->get();
     return view('functionally.crawler', compact('qGetTags', 'qGetCategories', 'allLinks'));
 }
Beispiel #7
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validation = Validator::make(Input::all(), $this->CreateRules);
     if ($validation->fails()) {
         if ($categoryFind = Categories::where('name', '=', Input::get('name'))->count()) {
             return Redirect::back()->withErrors($validation)->withInput();
         }
         return Redirect::back()->withErrors($validation)->withInput();
     }
     if ($validation->passes()) {
         $category = new Categories();
         $category->name = Input::get('name');
         if ($category->save()) {
             return Redirect::intended('admin/categories')->with('message', sprintf(trans('message.msg_category_create_success'), $category->name));
         }
         return Redirect::intended('admin/categories')->withErrors(array('errors' => sprintf(trans('message.msg_category_update_fail'), Input::get('name'))));
     }
     return Redirect::back()->with('warning', trans('message.msg_category_input_error'))->withErrors($validation)->withInput();
 }
Beispiel #8
0
 public function allcategories()
 {
     $dataCategory = Categories::where('flagactive', '!=', 0)->select('pu_categories.*', DB::raw('CONCAT("' . asset('') . '", picture) AS picture'))->get();
     return $dataCategory;
 }
 public function categories()
 {
     $categories = Categories::where('parent_id', -1)->get();
     return view('categories')->with('categories', $categories)->with('active_menu', 'categories');
 }