Ejemplo n.º 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $category = CategoryService::getInstance()->getCategorySelectTree();
     $category = ViewHelper::getInstance()->categoryTreeSelect($category);
     $this->viewData('category', $category);
     $info = Category::find($id);
     $info = is_null($info) ? [] : $info->toArray();
     $this->viewData('info', $info);
     $this->tips['修改'] = null;
     $this->viewData('tips', $this->tips);
     return $this->view('category.edit', $this->viewData);
 }
 /**
  * Test testLimitTextByWords()
  *
  * @return void
  */
 public function testLimitTextByWords()
 {
     // Set string
     $str = 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two twenty-three twenty-four twenty-five twenty-six twenty-seven';
     // Extected result is twenty five words
     $expectedResult = 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two twenty-three twenty-four twenty-five';
     // Sets string to twenty five words
     $result = ViewHelper::limitTextByWords($str);
     // Checks that expected and results match
     $this->assertEquals($expectedResult, $result);
 }
 /**
  *
  * Holds all meta data for show method
  *
  */
 protected function setMetaData($events)
 {
     // Grabs event title for specific event
     $metaTitle = $events['title'];
     // Setting eventTags to empty string
     $metaKeywords = '';
     if (!empty($tags)) {
         // Pulls tags only from array
         $metaKeywords = array_column($tags, 'tag');
         // Makes array into string to show in view
         $metaKeywords = implode(",", $metaKeywords);
     }
     $metaDescription = $events['description'];
     // Splitting description to only display 25 words
     $metaDescription = ViewHelper::limitTextByWords($metaDescription, 25);
     return ['metaTitle' => $metaTitle, 'metaKeywords' => $metaKeywords, 'metaDescription' => $metaDescription];
 }