/** * Store a newly created resource in storage. * * @return Response */ public function store(TagRequest $request) { $tag = new \App\Tag($request->all()); $tag->save(); \Session::flash('create_new_tag', 'Your tag has been created.'); return redirect('admin/tag'); }
/** * Create fake tag * * @return \App\Tag */ private function createFakeTag() { $faker = Faker\Factory::create(); $tag = new \App\Tag(); $tag->title = $faker->word; $tag->save(); return $tag; }
/** * Store a newly created resource in storage. * Tags have user_id and name * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $tag = new \App\Tag(); $tag->user_id = Auth::user()->id; $tag->name = $request->name; $tag->save(); return $tag; }
public function store(Request $request) { $this->validate($request, ['name' => 'required|unique:tags,name']); $tag = new \App\Tag(); $tag->name = strtolower($request->input('name')); $tag->save(); return redirect('backend/tags' . $tag->id); }
/** * Run the database seeds. * * @return void */ public function run() { $data = ['novel', 'fiction', 'classic', 'wealth', 'women', 'autobiography', 'nonfiction']; foreach ($data as $tagName) { $tag = new \App\Tag(); $tag->name = $tagName; $tag->save(); } }
/** * Run the database seeds. * * @return void */ public function run() { $data = ['Hybrid', 'Fuel Cell', 'Sedan', 'Mini Van', 'SUV', 'Wagon', 'Truck', 'Hatchback', 'Coupe', 'Premium', 'Luxury', 'Convertible', 'Specialty Car']; foreach ($data as $tagName) { $tag = new \App\Tag(); $tag->name = $tagName; $tag->save(); } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // $tag = new \App\Tag(); $tag->user_id = Auth::user()->id; $tag->name = $request->name; $tag->save(); return $tag; }
/** * Run the database seeds. * * @return void */ public function run() { $tags = ['Bangkok', 'Bilbao', 'Buddhism', 'Camino del Norte', 'Camino Inglès', 'Chenab Valley', 'Chiang Mai', 'climbing', 'cycling', 'Delhi', 'gold', 'Himachal Pradesh', 'holy man', 'Jammu & Kashmir', 'Indian Railways', 'Kangra Valley', 'Keylong', 'Khardung', 'Khardung La', 'Kunzum La', 'Ladakh', 'Leh', 'monastery', 'mural', 'narrow-gauge', 'Nubra Valley', 'Orissa', 'Panji Valley', 'pedal-powered', 'portrait', 'prayer flags', 'prayer wheel', 'Sinthan Top', 'Spiti', 'Srinagar', 'Stanage', 'Tamil Nadu', 'trohloff', 'West Bengal']; foreach ($tags as $tagName) { $tag = new \App\Tag(); $tag->name = $tagName; $tag->save(); } }
/** * Run the database seeds. * * @return void */ public function run() { $data = ['php', 'mysql', 'js', 'html', 'forms', 'front-end', 'css']; foreach ($data as $tagName) { $tag = new \App\Tag(); $tag->name = $tagName; $tag->save(); } }
/** * Run the database seeds. * * @return void */ public function run() { $data = ['mysql', 'security', 'php', 'model', 'view', 'controller', 'nonfiction', 'ui', 'css', 'js', 'html']; foreach ($data as $tagName) { $tag = new \App\Tag(); $tag->name = $tagName; $tag->save(); } }
public function update(Request $request, $id) { $station = \App\Station::findOrFail($id); if (!$request->user()->isAdmin() && $station->user_id != $request->user()->id) { return abort(403); } $this->validate($request, ['name' => 'required', 'description' => '', 'unique_id' => 'required|unique:stations,unique_id,' . $station->id, 'lat' => 'required', 'lng' => 'required']); $station->name = $request->input('name'); $station->description = $request->input('description', ''); $station->unique_id = $request->input('unique_id'); $station->lat = $request->input('lat'); $station->lng = $request->input('lng'); $station->save(); $tags = []; foreach ($request->get('tags', $station->tags()->lists('name')->toArray()) as $tag) { if ($tag == "") { continue; } $t = \App\Tag::where('name', $tag)->first(); if (!$t) { $t = new \App\Tag(); $t->name = strtolower($tag); $t->save(); } $tags[] = $t->id; } $station->tags()->sync(array_unique($tags)); return redirect('backend/stations/' . $station->id); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); $tag_ids = []; $users = []; $nodes = []; static::nodeRecurse($nodes); for ($a = 1; $a <= 5; $a++) { $tag = new \App\Tag(); $faker->seed($a + 10); $tag->name = $faker->word; $tag->save(); $tag_ids[] = $tag->id; } $faker->unique(true); for ($b = 1; $b <= 20; $b++) { $user = new \App\User(); $faker->seed($a); $user->name = $faker->unique()->userName; $user->email = $faker->unique()->email; $user->password = $faker->password; $user->save(); $users[] = $user; } foreach ($users as $user) { $faker->seed($user->id); if ($faker->boolean(40)) { // Author $author = new \App\Author(); $author->user()->associate($user); $author->name = $faker->name; $author->save(); if ($faker->boolean(50)) { $number_of_likes = $faker->numberBetween(1, count($users)); $faker->unique(true); for ($c = 1; $c <= $number_of_likes; $c++) { $like = new \App\Like(); $user_key = $faker->unique()->randomElement(array_keys($users)); $like->user()->associate($users[$user_key]); $like->likeable()->associate($author); $like->save(); } } if ($faker->boolean(20)) { $number_of_reports = $faker->numberBetween(1, round(count($users) / 3)); $faker->unique(true); for ($d = 1; $d <= $number_of_reports; $d++) { $report = new \App\Report(); $user_key = $faker->unique()->randomElement(array_keys($users)); $report->user()->associate($users[$user_key]); $report->save(); $report->authors()->attach($author); } } if ($faker->boolean(75)) { // At leat 1 article $article_count = $faker->numberBetween(1, 15); for ($e = 1; $e < $article_count; $e++) { $article = new \App\Article(); $article->author()->associate($author); $article->title = $faker->sentence($faker->numberBetween(3, 10)); $article->body = $faker->paragraphs($faker->numberBetween(2, 8), true); $article->node()->associate($faker->randomElement($nodes)); $article->save(); $article->tags()->sync($faker->randomElements($tag_ids, $faker->numberBetween(0, min(3, count($tag_ids))))); if ($faker->boolean(10)) { $number_of_reports = $faker->numberBetween(1, round(count($users) / 3)); $faker->unique(true); for ($f = 1; $f <= $number_of_reports; $f++) { $report = new \App\Report(); $user_key = $faker->unique()->randomElement(array_keys($users)); $report->user()->associate($users[$user_key]); $report->save(); $report->articles()->attach($article); } } if ($faker->boolean(90)) { $review = new \App\Review(); $user_key = $faker->randomElement(array_keys($users)); $review->user()->associate($users[$user_key]); $review->reviewable()->associate($article); $review->save(); } if ($faker->boolean(69)) { $number_of_likes = $faker->numberBetween(1, count($users)); $faker->unique(true); for ($g = 1; $g <= $number_of_likes; $g++) { $like = new \App\Like(); $user_key = $faker->unique()->randomElement(array_keys($users)); $like->user()->associate($users[$user_key]); $like->likeable()->associate($article); $like->save(); } } } if ($faker->boolean(70)) { // At leat 1 comment $comment_count = $faker->numberBetween(1, 20); for ($h = 1; $h < $comment_count; $h++) { $comment = new \App\Comment(); $comment->article()->associate($article); $comment->user()->associate($user); $comment->body = $faker->paragraph(4, true); $comment->save(); if ($faker->boolean(15)) { $number_of_reports = $faker->numberBetween(1, round(count($users) / 3)); $faker->unique(true); for ($i = 1; $i <= $number_of_reports; $i++) { $report = new \App\Report(); $user_key = $faker->unique()->randomElement(array_keys($users)); $report->user()->associate($users[$user_key]); $report->save(); $report->comments()->attach($comment); } } if ($faker->boolean(90)) { $review = new \App\Review(); $user_key = $faker->randomElement(array_keys($users)); $review->user()->associate($users[$user_key]); $review->reviewable()->associate($comment); $review->save(); } if ($faker->boolean(60)) { $number_of_likes = $faker->numberBetween(1, count($users)); $faker->unique(true); for ($j = 1; $j <= $number_of_likes; $j++) { $like = new \App\Like(); $user_key = $faker->unique()->randomElement(array_keys($users)); $like->user()->associate($users[$user_key]); $like->likeable()->associate($comment); $like->save(); } } } } } } } }
/** * Run the database seeds. * * @return void */ public function run() { /* DB::table('tags')->insert([ 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'tag' => 'ethnic', ]); DB::table('tags')->insert([ 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'tag' => 'bridge', ]); DB::table('tags')->insert([ 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'tag' => 'statue', ]); DB::table('tags')->insert([ 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'tag' => 'metallic', ]); DB::table('tags')->insert([ 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'tag' => 'Harvard', ]); DB::table('tags')->insert([ 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'tag' => 'gate', ]); DB::table('tags')->insert([ 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'tag' => 'scenic', ]); DB::table('tags')->insert([ 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'tag' => 'academic', ]); DB::table('tags')->insert([ 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'tag' => 'Chinese', ]); DB::table('tags')->insert([ 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'tag' => 'large', ]); */ $data = ['ethnic', 'bridge', 'statue', 'metallic', 'Harvard', 'scenic', 'gate', 'academic', 'Chinese', 'large']; foreach ($data as $tagName) { $tag = new \App\Tag(); $tag->tag = $tagName; $tag->save(); } }