public function store(TagRequest $request) { $tag = new Tag($request->all()); $tag->save(); Flash::success("Se ha agregado el tag " . $tag->name . " de manera exitosa!"); return redirect()->route('admin.tags.index'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(TagRequest $request) { $tag = new Tag($request->all()); $tag->save(); Flash::success('El tag ' . $tag->name . ' ha sido creado con éxito.'); return redirect()->route('admin.tags.index'); }
public function store(TagRequest $request) { $tag = new Tag($request->all()); $tag->save(); Flash::success('El tag ' . $tag->nombre . ' se registro con exito!!'); return redirect()->route('admin.tags.index'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(TagRequest $request) { $tag = new Tag($request->all()); $tag->save(); Flash::success("El tag " . $tag->name . " ha sido creada exitosamente"); return redirect()->route('admin.tags.index'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['new-post-tag' => 'required']); $tag = new Tag(array('title' => $request->get('new-post-tag'), 'slug' => str_slug($request->get('new-post-tag')))); $tag->save(); return $this->getAllTags(); }
public function store_tag(Request $request) { $name = $request->name; $tag = new Tag(); $tag->name = $name; $tag->save(); return redirect('manage/producttags'); }
/** * Store a newly created resource in storage. * * @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; }
private function seedTags($faker) { foreach (range(0, 100) as $number) { $tag = new Tag(); $tag->name = $faker->word; $tag->save(); } }
private function seedTags($faker) { foreach (range(0, 100) as $item) { $tag = new Tag(); $tag->title = $faker->word; // $tag->prova = $faker->boolean(); $tag->save(); } }
private function seedTags($faker) { foreach (range(0, 100) as $number) { $tag = new Tag(); $tag->title = $faker->word; // $tag->onoff =$faker->boolean; $tag->save(); } }
public function store(TagRequest $request) { //$this->createTags($request); $tag = new Tag(); $tag->name = $request->input('name'); $tag->save(); \Session::flash('flash_message', 'Tag has been added!'); return redirect('tags'); }
/** * Store the newly created tag in the database. * * @param TagCreateRequest $request * @return Response */ public function store(TagCreateRequest $request) { $tag = new Tag(); foreach (array_keys($this->fields) as $field) { $tag->{$field} = $request->get($field); } $tag->save(); return redirect('/admin/tag')->withSuccess("The tag '{$tag->tag}' was created."); }
public function seedTags($faker) { foreach (range(0, 100) as $number) { $tag = new Tag(); $tag->name = $faker->word; $tag->random_bool = $faker->boolean; $tag->save(); } }
private function sendTags($faker) { foreach (range(0, 100) as $number) { $tag = new Tag(); $tag->name = $faker->word; //$tag->tran = $faker->boolean; $tag->save(); } }
/** * @param Faker $faker */ private function seedTags(Faker $faker) { foreach (range(0, 100) as $item) { $tag = new Tag(); $tag->name = $faker->world; $tag->prova = $faker->boolean(); $tag->save(); } }
public function actionCreate(Requests\CreateTagRequest $request) { // Create a new model instance and populate it with the request. $tag = new Tag($request->all()); // Save tag in database. $tag->save(); // Redirect with flash message. \Session::flash('flash_message', 'You have successfully created a tag.'); return redirect('tags'); }
/** * Return redirect - creates new tag * * @return \Illuminate\View\View */ public function store($team, $feed_id) { $name = Input::get('name'); $network = $request->input('network'); $tag = new Tag(); $tag->title = $name; $tag->feed_id = $feed_id; $tag->network_id = $network; $tag->save(); return redirect('/team/' . $team->slug . '/feed/' . $feed_id); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { try { $tag = new Tag(); $tag->name = $request->input('name'); $tag->save(); return response()->json(array('error' => false, 'message' => 'Tag added successfully.'), 200); } catch (Exception $e) { throw $e; } }
/** * Store a newly created resource in storage. * * @param TagRequest $request * @return Response */ public function store(TagRequest $request) { $Tag = new Tag(); $Tag->name = $request->get('name'); $Tag->email = $request->get('email'); $Tag->password = bcrypt($request->get('password')); if ($Tag->save()) { return Redirect::route('back.blog.tags.index')->with('message', 'Successfully created record!')->with('message-class', 'success'); } else { return Redirect::route('back.blog.tags.create')->with('message', 'Whooops! Could not create the record.')->with('message-class', 'error')->withInputs(); } }
public function create(array $attributes) { $tags = Tag::all(); foreach ($tags as $temp) { if ($attributes == $temp->title) { return $temp; } } $tag = new Tag(); $tag->title = $attributes['title']; $tag->save(); return $tag; }
public function save(Request $request) { $tag = null; if ($request->id) { //edit $tag = Tag::find($request->id); } else { //new $tag = new Tag(); } $tag->title = $request->title; $tag->save(); return $tag; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $tag = new Tag(); $tag->name = "news"; $tag->slug = "news"; $tag->save(); $tag = new Tag(); $tag->name = "Technology"; $tag->slug = "Technology"; $tag->save(); $tag = new Tag(); $tag->name = "sports"; $tag->slug = "sports"; $tag->save(); }
private function ConvertTagsToList($tags) { foreach ($tags as $tag) { if (!is_numeric($tag)) { $new_tag = new Tag(); $new_tag->tag = $tag; $new_tag->save(); //save the type //remove it from the array $tags = array_diff($tags, array($tag)); $lastTagId = $new_tag->id; array_push($tags, $lastTagId); } } return $tags; }
/** * Store a newly created resource in storage. * * @param TagRequest $request * @return Response */ public function store(TagRequest $request) { $request->set('page_image', $this->upload($request->file('page_image'))); $Tag = new Tag(); $Tag->reverse_direction = $request->get('reverse_direction'); $Tag->meta_description = $request->get('meta_description'); $Tag->page_image = $request->get('page_image'); $Tag->subtitle = $request->get('subtitle'); $Tag->layout = $request->get('layout'); $Tag->title = $request->get('title'); $Tag->tag = $request->get('tag'); if ($Tag->save()) { return Redirect::route('back.blog.tags.index')->with('message', 'Successfully created record!')->with('message-class', 'success'); } else { return Redirect::route('back.blog.tags.create')->with('message', 'Whooops! Could not create the record.')->with('message-class', 'error')->withInputs(); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['title' => 'required|max:255', 'category_id' => 'required|numeric']); $tag = new Tag(); $count = $tag->count(); if ($request->sort_id > 0) { $tag->sort_id = $request->sort_id; } else { $tag->sort_id = ++$count; } $tag->category_id = $request->category_id; $tag->slug = str_slug($request->title); $tag->title = $request->title; if ($request->status == 'on') { $tag->status = 1; } else { $tag->status = 0; } $tag->save(); return redirect()->back()->with('status', 'Тег создан!'); }
public function insertQuery(Request $request) { $type = $request->input('type'); $tag = $request->input('tags'); $id = $request->input('id'); $mode = $request->input('mode'); //////////////////////////////////// //mode = 0 edit , mode = 1 insert/// //////////////////////////////////// if ($type == 'events') { $validator = Validator::make($request->all(), ['title' => 'required', 'address' => 'required', 'body' => 'required', 'tags' => 'required|array']); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'events', 'tags' => $this->returnTags())); } else { if ($mode == 1) { $event = new Event(); $content = new Content(); } else { $event = Event::find($id); $content = $event->content; } $content->title = $request->input('title'); $event->address = $request->input('address'); $content->body = $request->input('body'); $content->type = $type; $content->save(); $start = $request->input('start-day') . "|" . $request->input('start-month') . "|" . $request->input('start-year') . "|" . $request->input('start-hour') . ":" . $request->input('start-minute'); $end = $request->input('end-day') . "|" . $request->input('end-month') . "|" . $request->input('end-year') . "|" . $request->input('end-hour') . ":" . $request->input('end-minute'); $event->start = $start; $event->end = $end; $event->highlight = $request->input('highlight') == NULL ? 0 : 1; $files = $request->file('img'); foreach ($files as $file) { if ($file->isValid()) { $photo = new Photo(); $tempName = $file->getClientOriginalName(); $extension = explode(".", $tempName); $name = $extension[0] . "-" . time() . "." . $extension[1]; $destination = 'upload'; $file->move($destination, $name); $photo->path = $destination . "/" . $name; $content->photos()->save($photo); } } if (!empty($tag)) { foreach ($tag as $insertTag) { $row = Tag::where('title', '=', $insertTag)->first(); $content->tags()->save($row); } } $cat = Category::where('title', '=', $request->input('category'))->first(); if ($cat != null) { $content->categories()->attach($cat->id); } $content->event()->save($event); return redirect('admin'); } } elseif ($type == 'members') { $validator = Validator::make($request->all(), ['firstname' => 'required', 'lastname' => 'required', 'email' => 'required']); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'members', 'tags' => $this->returnTags())); } else { if ($mode == 1) { $member = new Member(); } else { $member = Member::find($id); } $member->firstname = $request->input('firstname'); $member->lastname = $request->input('lastname'); $member->email = $request->input('email'); //$member->password = $request->input('password'); $member->researchareas = $request->input('researchareas') == NULL ? NULL : $request->input('researchareas'); $member->industrialareas = $request->input('intery') == NULL ? NULL : $request->input('industry'); $member->tel = $request->input('telephone') == NULL ? NULL : $request->input('telephone'); $member->mobile = $request->input('mobile') == NULL ? NULL : $request->input('mobile'); $member->position = $request->input('position') == NULL ? NULL : $request->input('position'); $member->googleplus = $request->input('googleplus') == NULL ? NULL : $request->input('pinterest'); $member->facebook = $request->input('facebook') == NULL ? NULL : $request->input('facebook'); $member->twitter = $request->input('twitter') == NULL ? NULL : $request->input('instagram'); $member->linkedin = $request->input('linkedin') == NULL ? NULL : $request->input('linkedin'); if ($request->hasFile('img')) { $file = $request->file('img'); if ($file->isValid()) { $photo = new Photo(); $tempName = $file->getClientOriginalName(); $extension = explode(".", $tempName); $name = $extension[0] . "-" . time() . "." . $extension[1]; $destination = 'upload'; $file->move($destination, $name); //$photo->title = $request->input('photoTitle'); $photo->path = $destination . "/" . $name; Photo::where("member_id", $member->id)->delete(); $member->photo()->save($photo); } } if ($request->hasFile('cv')) { $file = $request->file('cv'); if ($file->isValid()) { $tempName = $file->getClientOriginalName(); $extension = explode(".", $tempName); $name = $extension[0] . "-" . time() . "." . $extension[count($extension) - 1]; $destination = 'upload'; $file->move($destination, $name); $member->cv = $destination . "/" . $name; } } $member->save(); if ($mode == 0) { $record = Member::find($id)->records; foreach ($record as $rec) { $rec->delete(); } } $recordArray = $request->input('rec'); if (!empty($recordArray)) { foreach ($recordArray as $key) { if (empty($key['delete'])) { $key['delete'] = 'off'; } if ($key['delete'] != "on" && $key['institute'] != "") { $record = new Record(); $record->institute = $key['institute']; $record->position = $key['position']; $record->start = $key['start']; $record->end = $key['end']; $record->type = $key['type']; $member->records()->save($record); } } } // $cat = Category::where('title', '=', $request->input('category'))->first(); return redirect('admin'); } } elseif ($type == 'researches') { $validator = Validator::make($request->all(), ['author' => 'required', 'title' => 'required', 'abstract' => 'required']); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'researches', 'tags' => $this->returnTags())); } else { if ($mode == 1) { $research = new Research(); $content = new Content(); } else { $research = Research::find($id); $content = $research->content; } $content->title = $request->input('title'); $content->body = $request->input('abstract'); $content->type = $type; $content->save(); $research->author = $request->input('author'); $research->publisher = $request->input('publisher') == NULL ? NULL : $request->input('publisher'); $date = $request->input('date-year') . "|" . $request->input('date-month') . "|" . $request->input('date-day') . "|" . $request->input('date-hour') . ":" . $request->input('date-minute'); $research->date = $date; $research->external = $request->input("external") == NULL ? true : false; $research->pages = $request->input('pages') == NULL ? NULL : $request->input('pages'); // $research->abstract = $request->input('abstract') == NULL ? NULL : $request->input('abstract'); $research->keywords = $request->input('keywords') == NULL ? NULL : $request->input('keywords'); $research->link = $request->input('link') == NULL ? NULL : $request->input('link'); $path = $request->file('path'); if (!empty($path) && $path->isValid()) { $tempName = $path->getClientOriginalName(); $extension = explode(".", $tempName); $name = $extension[0] . time() . "." . $extension[count($extension) - 1]; $destination = 'upload'; $path->move($destination, $name); $research->path = $destination . "/" . $name; } if (!empty($tag)) { foreach ($tag as $insertTag) { $row = Tag::where('title', '=', $insertTag)->first(); $content->tags()->save($row); } } $research->content()->associate($content); $research->save(); $cat = Category::where('title', '=', $request->input('category'))->first(); if ($cat != null) { $content->categories()->attach($cat->id); } return redirect('admin'); } } elseif ($type == 'galleries') { $validator = Validator::make($request->all(), ['title' => 'required', 'body' => 'required']); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'galleries', 'tags' => $this->returnTags())); } else { if ($mode == 1) { $content = new Content(); } else { $content = Content::find($id); } $content->title = $request->input('title'); $content->body = $request->input('body'); $content->type = $type; $content->save(); if ($request->hasFile('img')) { $file = $request->file('img'); for ($i = 0; $i < count($file); $i++) { if ($file[$i]->isValid()) { $photo = new Photo(); $tempName = $file[$i]->getClientOriginalName(); $extension = explode(".", $tempName); $name = $extension[0] . "-" . time() . (string) $i . "." . $extension[count($extension) - 1]; $destination = 'upload'; $file[$i]->move($destination, $name); $photo->title = $request->input('imgtitle')[$i]; $photo->path = $destination . "/" . $name; $photo->highlight = $request->input("highlight")[$i] == "true" ? 1 : 0; $content->photos()->save($photo); } } } if ($mode != 1) { if (!empty($request->input('oldimg'))) { foreach ($request->input('oldimg') as $img) { if (empty($img['delete'])) { $img['delete'] = "off"; $image = Photo::find($img['id']); $image->title = $img['title']; $image->highlight = $img['highlight'] == "true" ? 1 : 0; $image->save(); } if ($img['delete'] == "on") { $temp = Photo::find($img['id']); $temp->delete(); } } } } if (!empty($tag)) { foreach ($tag as $insertTag) { $row = Tag::where('title', '=', $insertTag)->first(); $content->tags()->save($row); } } $cat = Category::where('title', '=', $request->input('category'))->first(); if ($cat != null) { $content->categories()->attach($cat->id); } return redirect('admin'); } } elseif ($type == 'tags') { $input = $request->all(); $split = explode("#", $input['body']); for ($i = 0; $i < count($split); $i++) { if (!empty($split[$i]) && $split[$i] != '') { $tag = new Tag(); $tag->title = trim($split[$i]); $tag->save(); } } return redirect('admin'); } elseif ($type == 'categories') { $cat = new Category(); $cat->title = $request->input("title"); $cat->parent = $request->input("cat-id"); if ($cat->parent == 0) { $cat->parent = null; } $cat->save(); return redirect('admin'); } elseif ($type == "variables") { $var = Variable::find($id); $var->title = $request->input("title"); $var->subtitle = $request->input("subtitle"); $var->body = $request->input("body"); if ($request->hasFile('img')) { $file = $request->file('img'); if ($file->isValid()) { $tempName = $file->getClientOriginalName(); $extension = explode(".", $tempName); $name = $extension[0] . "-" . time() . "." . $extension[count($extension) - 1]; $destination = 'upload'; $file->move($destination, $name); //$photo->title = $request->input('photoTitle'); $var->body = $destination . "/" . $name; } } $var->save(); return redirect('admin'); } else { $validator = Validator::make($request->all(), ['title' => 'required', 'body' => 'required', 'tags' => 'required|array']); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'news', 'tags' => $this->returnTags())); } else { if ($mode == 1) { $news = new Content(); } else { $news = Content::find($id); } $news->title = $request->input('title'); $news->body = $request->input('body'); $news->type = $type; $news->save(); if ($request->hasFile('img')) { $files = $request->file('img'); if ($mode == 0) { $oldphoto = Photo::where("content_id", $id)->first(); $oldphoto->delete(); } foreach ($files as $file) { if ($file->isValid()) { $photo = new Photo(); $tempName = $file->getClientOriginalName(); $extension = explode(".", $tempName); $name = $extension[0] . "-" . time() . "." . $extension[count($extension) - 1]; $destination = 'upload'; $file->move($destination, $name); //$photo->title = $request->input('photoTitle'); $photo->path = $destination . "/" . $name; $news->photos()->save($photo); } } } if (!empty($tag)) { foreach ($tag as $insertTag) { $row = Tag::where('title', '=', $insertTag)->first(); $news->tags()->save($row); } } $cat = Category::find($request->input('cat-id')); if ($cat != null) { $news->categories()->attach($cat->id); } return redirect('admin'); } } }
public function run() { DB::table('tags')->delete(); //サンプルタグ作成 $tag = new Tag(); $tag->name = '大人でも楽しめる'; $tag->created_at = Carbon::now(); $tag->updated_at = Carbon::now(); $tag->save(); //サンプルタグ作成 $tag = new Tag(); $tag->name = '駐車場あり'; $tag->created_at = Carbon::now(); $tag->updated_at = Carbon::now(); $tag->save(); //サンプルタグ作成 $tag = new Tag(); $tag->name = '未就学児向け'; $tag->created_at = Carbon::now(); $tag->updated_at = Carbon::now(); $tag->save(); //サンプルタグ作成 $tag = new Tag(); $tag->name = '小学校低学年向け'; $tag->created_at = Carbon::now(); $tag->updated_at = Carbon::now(); $tag->save(); //サンプルタグ作成 $tag = new Tag(); $tag->name = '小学校高学年向け'; $tag->created_at = Carbon::now(); $tag->updated_at = Carbon::now(); $tag->save(); }
public function postStore($id = null) { // ---------------------------------------- HANDLE REQUEST ---------------------------------------- // handle id if (!is_null($id)) { $data = $this->model->findorfail($id); } else { $data = $this->model->newInstance(); } // ---------------------------------------- CHECK TAG ---------------------------------------- $tags_in_db = \App\Tag::whereIn('tag', Input::get('tags'))->get(); if (!$tags_in_db) { $tags_in_db = new Collection(); } foreach (Input::get('tags') as $x) { if (!$tags_in_db->where('tag', $x)->first()->id) { $new_tag = new \App\Tag(['tag' => $x]); if (!$new_tag->save()) { dd($new_tag->getErrors()); } $tags_in_db->push($new_tag); } } // ---------------------------------------- HANDLE SAVE ---------------------------------------- $input = Input::all(); if (!empty($input['published_at'])) { $input['published_at'] = \Carbon\Carbon::createFromFormat('d/m/Y H:i', $input['published_at'])->format('Y-m-d H:i:s'); } else { $input['published_at'] = null; } unset($input['longlat']); $input['tag_ids'] = $tags_in_db->pluck('id')->toArray(); $data->fill($input); if ($data->save()) { if (!$this->save_required_images($data, $input)) { return redirect()->back()->withInput()->withErrors($data->getErrors()); } return redirect()->route('admin.' . $this->view_name . '.show', ['id' => $data->id])->with('alert_success', '"' . $data->{$data->getNameField()} . '" has been saved successfully'); } else { return redirect()->back()->withInput()->withErrors($data->getErrors()); } }
public function update(Request $request, Blog $blog) { $user = Sentinel::getUser()->id; $rules = ['title' => 'required|min:5|max:150|alpha_num', 'content' => 'required|min:10']; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return back()->withInput()->withErrors($validator); } else { # Create Blog $blog = Blog::find($blog->id); $blog->title = $request->title; $blog->content = $request->content; $blog->user_id = $user; # Redirect on Success if ($blog->save()) { $tags = $request->tags; foreach ($tags as $tag) { if (is_numeric($tag)) { $tagabledeletedRows = Taggable::where('tag_id', $tag)->delete(); $tagableSave = new Taggable(); $tagableSave->taggable_id = $blog->id; $tagableSave->tag_id = $tag; $tagableSave->taggable_type = 'App\\Blog'; $tagableSave->user_id = $user; $tagableSave->save(); } else { if (strlen($tag) >= 3) { $tagExist = Tag::where('text', $tag)->count(); if ($tagExist == 0) { $tagSave = new Tag(); $tagSave->text = $tag; $tagSave->save(); } } } } return redirect()->route('user.blog.index')->with('success', trans('validation.blog_success')); } } return back()->withInput()->with('error', 'مشکل در اتصال به سرور. لطفا مجددا تلاش کنید.'); }
public function tags($num, $lead_id) { for ($i = 0; $i < $num; $i++) { $item = new Tag(); $item->name = $this->faker->word(); $item->lead_id = $lead_id; $item->save(); } }