本文整理汇总了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)]);
}
}
示例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');
}
示例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());
}
示例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()];
}
示例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);
}
}
示例6: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Tag::create(['name' => $faker->word]);
}
}
示例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);
}
示例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');
}
示例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']);
}
示例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()]);
}
}
示例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');
}
示例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'));
}
示例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');
}
示例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']);
}
示例15: createTags
protected function createTags()
{
$tags = [];
foreach ($this->tagNames as $tagName) {
$tags[] = Tag::create(['name' => $tagName]);
}
return $tags;
}