當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tag::create方法代碼示例

本文整理匯總了PHP中app\Tag::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tag::create方法的具體用法?PHP Tag::create怎麽用?PHP Tag::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Tag的用法示例。


在下文中一共展示了Tag::create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * 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)]);
     }
 }
開發者ID:khaled-barca,項目名稱:MyTunnelVision,代碼行數:30,代碼來源:TableSeeder.php

示例2: store

 /**
  * 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');
 }
開發者ID:JhonatanC,項目名稱:laravelcodfa,代碼行數:13,代碼來源:TagsController.php

示例3: store

 /**
  * 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());
 }
開發者ID:nahid1991,項目名稱:LoginTest,代碼行數:32,代碼來源:TagController.php

示例4: postImport

 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()];
 }
開發者ID:newset,項目名稱:wx,代碼行數:27,代碼來源:Tags.php

示例5: run

 /**
  * 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);
     }
 }
開發者ID:ahmed-raza,項目名稱:lara_new,代碼行數:12,代碼來源:TagsTableSeeder.php

示例6: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Tag::create(['name' => $faker->word]);
     }
 }
開發者ID:SigurdMW,項目名稱:laracast-api-tutorial,代碼行數:7,代碼來源:TagsTableSeeder.php

示例7: store

 /**
  * 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);
 }
開發者ID:no-global-state,項目名稱:Mabbit,代碼行數:13,代碼來源:Tag.php

示例8: update

 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');
 }
開發者ID:Zlyy,項目名稱:adceg,代碼行數:31,代碼來源:AdvertsController.php

示例9: run

 /**
  * 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']);
 }
開發者ID:Clazance,項目名稱:developer-shame,代碼行數:30,代碼來源:TagTableSeeder.php

示例10: run

 /**
  * 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()]);
     }
 }
開發者ID:ambarsetyawan,項目名稱:laravel5-blog-1,代碼行數:12,代碼來源:TagsTableSeeder.php

示例11: store

 /**
  * 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');
 }
開發者ID:maherelgamil,項目名稱:ketabat,代碼行數:12,代碼來源:TagsController.php

示例12: run

 /**
  * 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'));
 }
開發者ID:pgalias,項目名稱:portfolio,代碼行數:12,代碼來源:TagTableSeeder.php

示例13: store

 /**
  * 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');
 }
開發者ID:abhatia2107,項目名稱:cat,代碼行數:13,代碼來源:TagController.php

示例14: run

 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']);
 }
開發者ID:izzach,項目名稱:Capstone,代碼行數:7,代碼來源:DatabaseSeeder.php

示例15: createTags

 protected function createTags()
 {
     $tags = [];
     foreach ($this->tagNames as $tagName) {
         $tags[] = Tag::create(['name' => $tagName]);
     }
     return $tags;
 }
開發者ID:albarincon,項目名稱:money-manager,代碼行數:8,代碼來源:TestCase.php


注:本文中的app\Tag::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。