Beispiel #1
0
 public function insert_tag($tag_data)
 {
     $tag = new Tags();
     $tag->tag = $tag_data;
     if ($tag->save()) {
         return TRUE;
     }
     return FALSE;
 }
 public function addAcademy(Request $request)
 {
     $imgArr = array();
     if (isset($_FILES["images"])) {
         $files_name = $_FILES["images"]["name"];
         $files_tmp = $_FILES["images"]["tmp_name"];
         $files_size = $_FILES["images"]["size"];
     }
     for ($i = 0; $i < sizeof($files_name); $i++) {
         $name = substr(md5($files_name[$i]), 0, 5);
         $ext = pathinfo($files_name[$i], PATHINFO_EXTENSION);
         $tempFile = $files_tmp[$i];
         $targetPath = "/uploads/";
         $mainName = time() . "-" . $name . "." . strtolower($ext);
         $resPath = $targetPath . $mainName;
         $mainFile = public_path() . $resPath;
         if ($files_size[$i] < 2097152) {
             if (move_uploaded_file($tempFile, $mainFile)) {
                 array_push($imgArr, $resPath);
             }
         }
     }
     try {
         $academy = new Academy();
         $academy->academy_name = $request->input("academy_name");
         $academy->timeslot = $request->input("timeslot");
         $academy->contact_person = $request->input("contact_person");
         $academy->email = $request->input("email");
         $academy->phone = $request->input("phone");
         $academy->address = $request->input("address");
         $academy->city = $request->input("city");
         $academy->country = $request->input("country");
         $academy->description = $request->input("content");
         $academy->latitude = $request->input("lat");
         $academy->longitude = $request->input("lon");
         $academy->save();
         $academy_id = $academy->academy_id;
         $tags = explode(",", $request->input("tags"));
         foreach ($tags as $tag) {
             $tagModel = new Tags();
             $tagModel->academy_id = $academy_id;
             $tagModel->tag_name = $tag;
             $tagModel->save();
         }
         foreach ($imgArr as $img) {
             $arti = new Artifacts();
             $arti->academy_id = $academy_id;
             $arti->artifact_url = $img;
             $arti->save();
         }
         return redirect()->action('AdminController@getIndex');
     } catch (\Illuminate\Database\QueryException $e) {
         //TODO : SHOW FLASH
         echo json_encode($e);
     }
 }
Beispiel #3
0
 public static function tag($rawHashtag, $postID)
 {
     preg_match_all('/#([a-zA-Z0-9 ]*)/', strtoupper($rawHashtag), $matches, PREG_PATTERN_ORDER);
     $arrayOfHT = $matches[1];
     foreach ($arrayOfHT as $aht) {
         $hashtag = Hashtags::where('Hashtag', 'LIKE', trim($aht))->get()->first();
         if (count($hashtag) < 1) {
             $hashtag = new Hashtags();
             $hashtag->Hashtag = trim($aht);
             $hashtag->save();
         }
         $hashtag = Hashtags::where('Hashtag', 'LIKE', trim($aht))->get()->first();
         $tag = new Tags();
         $tag->HashtagID = $hashtag->id;
         $tag->PostID = $postID;
         $tag->save();
     }
 }