当前位置: 首页>>代码示例>>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;未经允许,请勿转载。