/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::Create();
     foreach (range(1, 10) as $seededItem) {
         User::create(['first_name' => $faker->name, 'last_name' => $faker->name, 'password' => Hash::make('123456'), 'type' => false, 'sex' => $faker->boolean(), 'email' => $faker->email, 'date_of_birth' => $faker->date('Y-m-d')]);
     }
     $users = User::all()->lists('id')->toArray();
     foreach (range(1, 100) as $seededItem) {
         Post::create(['user_id' => $faker->randomElement($users), 'body' => $faker->text, 'vote_count' => 0]);
     }
     $posts = Post::all()->lists('id')->toArray();
     Comment::create(['user_id' => $faker->randomElement($users), 'body' => $faker->text, 'vote_count' => 0, 'parent_id' => null]);
     foreach (range(1, 100) as $seededItem) {
         Post_Vote::create(['user_id' => $faker->randomElement($users), 'post_id' => $faker->randomElement($posts), 'up' => $faker->boolean()]);
         Comment::create(['user_id' => $faker->randomElement($users), 'parent_id' => $faker->randomElement(Comment::all()->lists('id')->toArray()), 'post_id' => $faker->randomElement($posts), 'body' => $faker->text, 'vote_count' => 0]);
         Tag::create(['name' => $faker->text, 'private' => $faker->boolean()]);
     }
     $comments = Comment::all()->lists('id')->toArray();
     $tags = Tag::all()->lists('id')->toArray();
     foreach (range(1, 100) as $seededItem) {
         Comment_Vote::create(['user_id' => $faker->randomElement($users), 'comment_id' => $faker->randomElement($comments), 'up' => $faker->boolean()]);
         Tag_User::create(['user_id' => $faker->randomElement($users), 'tag_id' => $faker->randomElement($tags)]);
         Post_Tag::create(['tag_id' => $faker->randomElement($tags), 'post_id' => $faker->randomElement($posts)]);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(TagRequest $request)
 {
     $tag = Tag::create($request->all());
     $tag->save();
     Session::flash('message_create', "El tag - " . $request->name . " - fue creado exitosamente!");
     return redirect()->route('admin.tags.index');
 }
Beispiel #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(TagRequest $request)
 {
     $user = \Auth::user();
     //        $newTags = array();
     //        foreach(explode(" ", $request->input("name")) as $new)
     //        {
     //            $newTags = array("name" => $new);
     //            Tag::create($newTags);
     //        }
     $count = DB::table('tag_faculty')->where('username', $user->username)->count();
     if ($count < 4) {
         Tag::create($request->all());
         $forQuery = Tag::orderBy('created_at', 'desc')->first();
         DB::table('tag_faculty')->insert(['tag_id' => $forQuery->id, 'username' => $user->username]);
         //            $tags = DB::table('tag_faculty')
         //                ->join('tags', 'tag_faculty.tag_id', '=', 'tags.id')
         //                ->join('users', 'tag_faculty.username', '=', 'users.username')
         //                ->where('users.username', $user->username)
         //                ->get();
         return redirect('/dash-board');
     } else {
         $error = "Your tag limit has exceeded";
         return redirect('/dash-board')->withErrors($error);
     }
     //        dd($request->input('tags'));
     //        Tag::create($request->all());
 }
Beispiel #4
0
 public function postImport(Request $req)
 {
     $color = ['red', 'pink', 'blue', 'purple', 'green', 'yellow', 'indigo', 'cyan', 'lime', 'brown', 'orange', 'gray'];
     $data = [];
     $status = true;
     if ($req->input('tags')) {
         $data = explode("\n", $req->input('tags'));
         for ($i = 0; $i < count($data); $i++) {
             list($cate, $name) = explode('-', $data[$i]);
             $category = DB::table('categories')->where('name', $cate)->first();
             $cateId = 0;
             if ($category) {
                 $cateId = $category->id;
             } else {
                 $cateId = DB::table('categories')->insertGetId(['name' => $cate, 'color' => $color[rand(0, count($color) - 1)]]);
             }
             $tag = Tag::where('name', $name)->first();
             if ($tag) {
                 $tag->category_id = $cateId;
                 $tag->save();
             } else {
                 Tag::create(['name' => $name, 'category_id' => $cateId]);
             }
         }
     }
     return ['status' => $status, 'tags' => $this->getIndex()];
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $tags = [['name' => 'Work'], ['name' => 'Food'], ['name' => 'Personal'], ['name' => 'Coding'], ['name' => 'Apple']];
     foreach ($tags as $tag) {
         Tag::create($tag);
     }
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Tag::create(['name' => $faker->word]);
     }
 }
Beispiel #7
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|min:2']);
     $model = TagModel::create($request->all());
     \Session::flash('status', 'A tag has been created successfully');
     return redirect()->action('Tag@index', $model->id);
 }
Beispiel #8
0
 public function update($id, CreateAdvertRequest $request)
 {
     $advert = Adverts::findOrFail($id);
     $hasImg = $advert->image;
     $advert->update($request->all());
     if ($request->file('image')) {
         $imageName = $advert->id . '.' . $request->file('image')->getClientOriginalExtension();
         $request->file('image')->move(public_path() . '/public/images/', $imageName);
         $advert->image = '/public/images/' . $imageName;
         $advert->update();
     }
     if ($hasImg) {
         $advert->image = $hasImg;
         $advert->update();
     }
     if ($request->input('tags_list')) {
         $tags = $request->input('tags_list');
         $currentTags = array_filter($tags, 'is_numeric');
         $newTags = array_diff($tags, $currentTags);
         foreach ($newTags as $newTag) {
             if ($tag = Tag::create(['name' => $newTag])) {
                 $currentTags[] = $tag->id;
             }
         }
         $advert->tags()->sync($currentTags);
     } else {
         $advert->tags()->delete();
     }
     \Session::flash('flash_message', 'Twoje ogłoszenie zostało zapisane!');
     return redirect('adverts');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Tag::create(['title' => 'ActionScript']);
     Tag::create(['title' => 'AppleScript']);
     Tag::create(['title' => 'Asp']);
     Tag::create(['title' => 'BASIC']);
     Tag::create(['title' => 'C']);
     Tag::create(['title' => 'C++']);
     Tag::create(['title' => 'Clojure']);
     Tag::create(['title' => 'COBOL']);
     Tag::create(['title' => 'ColdFusion']);
     Tag::create(['title' => 'Erlang']);
     Tag::create(['title' => 'Fortran']);
     Tag::create(['title' => 'Groovy']);
     Tag::create(['title' => 'Haskell']);
     Tag::create(['title' => 'Java']);
     Tag::create(['title' => 'JavaScript']);
     Tag::create(['title' => 'Lisp']);
     Tag::create(['title' => 'Perl']);
     Tag::create(['title' => 'PHP']);
     Tag::create(['title' => 'Python']);
     Tag::create(['title' => 'Ruby']);
     Tag::create(['title' => 'Scala']);
     Tag::create(['title' => 'Scheme']);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 8) as $index) {
         \App\Tag::create(['name' => $faker->unique()->word, 'slug' => $faker->unique()->slug, 'created_at' => $faker->dateTimeThisYear(), 'updated_at' => $faker->dateTimeThisYear()]);
     }
 }
Beispiel #11
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(TagRequest $request)
 {
     Tag::create($request->all());
     // Success message
     \Flash::success('New Tag added.');
     return redirect('admin/tags');
 }
Beispiel #12
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('tag')->delete();
     Tag::create(array('name' => 'design'));
     Tag::create(array('name' => 'developing'));
     Tag::create(array('name' => 'sample'));
 }
Beispiel #13
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['tag' => 'required']);
     // Uncomment and modify if you need to validate any input.
     Tag::create($request->all());
     return redirect('tag');
 }
Beispiel #14
0
 public function run()
 {
     DB::table('tags')->delete();
     Tag::create(['id' => 1, 'name' => 'tag']);
     Tag::create(['id' => 2, 'name' => 'cat']);
     Tag::create(['id' => 3, 'name' => 'funny']);
 }
Beispiel #15
0
 protected function createTags()
 {
     $tags = [];
     foreach ($this->tagNames as $tagName) {
         $tags[] = Tag::create(['name' => $tagName]);
     }
     return $tags;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $tags = ['home', 'school', 'work', 'friends'];
     foreach ($tags as $tag) {
         Tag::create(['name' => $tag]);
     }
 }
Beispiel #17
0
 /** 
  * Save the tag
  * @param $request 
  */
 public function store(TagRequest $request)
 {
     // $input['published_at'] = Carbon::now();
     // Tag::create(Request::all());
     Tag::create($request->all());
     return redirect('tags');
     // return $input;
 }
Beispiel #18
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['nombre' => 'required|unique:tags,nombre']);
     $tag = Tag::create($request->all());
     $tag->save();
     Session::flash("message", "Se han guardado los datos!");
     return redirect()->route('tags.index');
 }
Beispiel #19
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     if (!Input::get('name') or !Input::get('done') or !Input::get('priority')) {
         return $this->setStatusCode(IlluminateResponse::HTTP_UNPROCESSABLE_ENTITY)->respondWithError('Parameters failed validation for a tag.');
     }
     Tag::create(Input::all());
     return $this->respondCreated('Tag successfully created.');
 }
Beispiel #20
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if (Tag::create($request->all())) {
         return redirect('tag');
     } else {
         dd('Error! Could not add tag!');
     }
 }
Beispiel #21
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $tags = ['Sport Climbing', 'Abseiling', 'Hiking', 'Trekking', 'Water sports', 'Others'];
     foreach ($tags as $tag) {
         Tag::create(['name' => $tag]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // TestDummy::times(20)->create('App\Post');
     // $this->call(UserTableSeeder::class);
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Tag::create(['name' => $faker->word]);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if ($request->user()->cannot('create-tag')) {
         abort(403);
     }
     $this->validate($request, ['level' => 'required|integer|between:0,255', 'name' => 'required|string|max:255']);
     $tag = Tag::create($request->only(['level']));
     $translation = TagTranslation::create(['tag_id' => $tag->id, 'locale' => 'en', 'name' => $request->input('name')]);
     return redirect()->action('TagController@edit', [$tag]);
 }
Beispiel #24
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     Tag::create(['name' => 'personal']);
     Tag::create(['name' => 'working']);
     Tag::create(['name' => 'coding']);
     Tag::create(['name' => 'food']);
     // $this->call(UserTableSeeder::class);
     Model::reguard();
 }
Beispiel #25
0
 /**
  * Tạo mới
  * 
  * @param TagRequest $request
  * @return Response
  */
 public function store(TagRequest $request, ImageInterface $image)
 {
     $data = $request->all();
     if ($request->hasFile('image')) {
         $image->init($request, 'tags')->save('large');
         $data = array_replace($data, ['image' => $image->name]);
     }
     Tag::create($data);
     return redirect('admin/tag')->with('flash_message', config('blog.message.created'));
 }
Beispiel #26
0
 public function syncTags(Article $article, $tags = array(), $isNew = false)
 {
     $tagall = Tag::all()->toArray();
     $newTagIds = $updateTagIds = $existingSlug = $existingTag = [];
     if (!empty($tagall)) {
         foreach ($tagall as $tag) {
             $existingSlug[] = $tag['slug'];
             $existingTag[$tag['slug']] = $tag;
         }
     }
     unset($tagall);
     if ($tags) {
         foreach ($tags as $tag) {
             if (!in_array(mb_strtolower($tag, 'UTF-8'), $existingSlug)) {
                 $name = filter_allowed_words($tag);
                 $slug = preg_replace('/\\s+/', '-', mb_strtolower($name, 'UTF-8'));
                 if (in_array($slug, $existingSlug)) {
                     if ($isNew) {
                         Tag::whereSlug($slug)->increment('count');
                     }
                     $updateTagIds[] = $existingTag[$slug]['id'];
                 } else {
                     $firstLetter = getFirstLetter($name);
                     $newtag = Tag::create(array('name' => $name, 'slug' => $slug, 'letter' => $firstLetter));
                     $newId = $newtag->id;
                     $newTagIds[] = $newId;
                     $updateTagIds[] = $newId;
                 }
             } else {
                 if ($isNew) {
                     Tag::whereSlug($tag)->increment('count');
                 }
                 $updateTagIds[] = $existingTag[$tag]['id'];
             }
         }
     }
     $updateTagIds = array_unique($updateTagIds);
     if (!$isNew) {
         $oldTagIds = $article->tags->lists('id')->toArray();
         $delTagIds = array_diff($oldTagIds, $updateTagIds);
         $addTagIds = array_diff($updateTagIds, $oldTagIds);
         if (!empty($delTagIds)) {
             Tag::whereIn('id', $delTagIds)->decrement('count');
         }
         if (!empty($addTagIds)) {
             foreach ($addTagIds as $addId) {
                 if (!in_array($addId, $newTagIds)) {
                     Tag::whereId($addId)->increment('count');
                 }
             }
         }
     }
     $article->tags()->sync($updateTagIds);
     unset($newTagIds, $updateTagIds, $existingSlug, $existingTag);
 }
Beispiel #27
0
 private function checkForNewTag($ttt)
 {
     $tags = Tag::lists("name", "id");
     var_dump($ttt);
     echo "<br/>";
     foreach ($ttt as $t) {
         if (in_array($t, $tags->toArray())) {
             App\Tag::create(["id" => $t]);
         }
     }
 }
Beispiel #28
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Tag::create(['name' => 'PHP']);
     Tag::create(['name' => 'CSS']);
     Tag::create(['name' => 'JS']);
     Tag::create(['name' => 'Development']);
     Tag::create(['name' => 'Maintenance']);
     Tag::create(['name' => 'Bug Fixing']);
     Tag::create(['name' => 'Testing']);
     Tag::create(['name' => 'Meeting']);
 }
 private function syncTags(Article $article, array $tags)
 {
     $currentTags = array_filter($tags, 'is_numeric');
     $newTags = array_diff($tags, $currentTags);
     foreach ($newTags as $newTag) {
         $tag = Tag::create(['name' => $newTag]);
         $tag->save();
         $currentTags[] = $tag->id;
     }
     $article->tags()->sync($currentTags);
 }
Beispiel #30
0
 public function create(Request $request)
 {
     $item = Tag::create($request->all());
     try {
         $item->save();
     } catch (\Exception $e) {
         $this->error[] = $e;
         return Answer::set(500, Lang::get('api.notEnoughData'));
     }
     return Answer::set(200, $item);
 }