/** * Include articles. * * @param \App\Tag $tag * @param \League\Fractal\ParamBag|null $params * @return \League\Fractal\Resource\Collection * @throws \Exception */ public function includeArticles(Tag $tag, ParamBag $params = null) { $transformer = new \App\Transformers\ArticleTransformer($params); $parsed = $this->getParsedParams(); $articles = $tag->articles()->limit($parsed['limit'])->offset($parsed['offset'])->orderBy($parsed['sort'], $parsed['order'])->get(); return $this->collection($articles, $transformer); }
/** * Display a listing of the resource associated with the tag name. * * @param Tag $tag * @return \Illuminate\Http\Response */ public function tagged(Tag $tag) { $admin = User::first(); $tags = Tag::all(); $articles = $tag->publishedArticles()->get(); $currentTag = $tag; return view($this->theme() . 'home', compact('articles', 'currentTag', 'admin', 'tags')); }
public function show(Tag $tag) { $articles = $tag->articles()->published('<')->get(); // if published date is not required then // below line can be used :) // $articles = $tag->articles return view('articles.index', compact('articles')); }
public function store_tag(Request $request) { $name = $request->name; $tag = new Tag(); $tag->name = $name; $tag->save(); return redirect('manage/producttags'); }
private function seedTags($faker) { foreach (range(0, 100) as $number) { $tag = new Tag(); $tag->name = $faker->word; $tag->save(); } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show(Tag $tag) { if (Auth::user() && Auth::user()->isAdmin()) { $posts = $tag->post()->simplePaginate(10); } else { $posts = $tag->post()->publics()->simplePaginate(10); } return view('tags.show', compact('posts', 'tag')); }
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'); }
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 seedTags($faker) { foreach (range(0, 100) as $item) { $tag = new Tag(); $tag->title = $faker->word; // $tag->prova = $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 destroy(Tag $tag) { if (!$tag->transactions->isEmpty()) { flash()->error('Tag cannot be removed while in use'); return redirect()->route('tag.index'); } $tag->delete(); flash()->success('Tag removed successfully'); return redirect()->route('tag.index'); }
public function all() { $tag = new Tag(); $all = Tag::all(['id', 'tag as text']); if (\Input::has('isWeekly')) { $weeklyTag = $tag->getRecentlyWeeklyTag(); return ['tags' => $all, 'wrTag' => $weeklyTag]; } return $all; }
public function show(Tag $tag) { // if (Gate::denies('update', $tag)) { // abort(403, Message::HTTP_403); // } // $this->authorize('update', $tag); // if (auth()->user()->can('update', $tag)) { // return 'You can'; // } $articles = $tag->articles()->paginate(5); return view('articles.index', compact('articles')); }
/** * 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(); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); $router->bind('articles', function ($id) { $article = Article::findOrFail($id); // If the owner return all articles else return only published. if (Auth::user() && $article->user_id === Auth::user()->id) { $articles = Article::findOrFail($id); } else { $articles = Article::published()->findOrFail($id); } return $articles; }); $router->bind('questions', function ($id) { return Question::findOrFail($id); }); $router->bind('answers', function ($id) { return Answer::findOrFail($id); }); $router->bind('tags', function ($name) { return Tag::where('name', $name)->firstOrFail(); }); $router->bind('users', function ($id) { return User::findOrFail($id); }); }
public function edit(Article $article) { $tags = Tag::lists("name", "id"); $published_at = Carbon::now(); $usert = $article->getTagListAttribute(); return view('articles.edit', compact('article', 'usert', 'published_at', 'tags')); }
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()]; }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); /** * Binding the model */ // $router->model('articles', 'App\Article'); /** * Optional custom bind */ $router->bind('articles', function ($id) { /** * Show only the published articles */ return \App\Article::published()->findOrFail($id); }); // $router->model('tags', 'App\Tag'); $router->bind('tags', function ($name) { /** * Show only the related same tag by name */ return \App\Tag::where('name', $name)->firstOrFail(); }); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $event = Event::find($id); $event->host = User::find($event->user_id); $event->host->userTags = self::getTagsForUser($event->host->id); $peopleCount = \DB::table('event_user')->where('event_id', $id)->where('status', 'approved')->count(); $event->players = \DB::table('event_user')->select('user_id')->where('event_id', $event->id)->where('status', 'approved')->get(); foreach ($event->players as $player) { $player->object = User::find($player->user_id); $player->object->userTags = self::getTagsForUser($player->object->id); } $is_host = false; $listTags = []; $tags = Tag::orderBy('name')->get(); foreach ($tags as $tag) { $listTags[$tag->id] = $tag->name; } if (\Auth::user()->id == $event->host->id) { $is_host = true; $requests = \DB::table('event_user')->where('event_id', $event->id)->where('status', 'pending')->get(); foreach ($requests as $request) { $request->user = User::find($request->user_id); } return view('events.show')->with('event', $event)->with('peopleCount', $peopleCount)->with('requests', $requests)->with('tags', $listTags)->with('is_host', $is_host); } else { $applied = \DB::table('event_user')->where('event_id', $event->id)->where('user_id', \Auth::id())->get(); if (empty($applied)) { $appliedStatus = 'not applied'; } else { $appliedStatus = $applied[0]->status; } return view('events.show')->with('event', $event)->with('peopleCount', $peopleCount)->with('is_host', $is_host)->with('applied', $applied)->with('tags', $listTags)->with('appliedStatus', $appliedStatus); } }
public function newTweet(Request $request) { $this->validate($request, ['content' => 'required|min:2|max:140']); $newTweet = new Tweet(); // point to columns in db $newTweet->content = $request->content; // user who is logged in take their id $newTweet->user_id = \Auth::user()->id; // Save into database $newTweet->save(); // Process the tags $tags = explode('#', $request->tags); $tagsFormatted = []; // clean up tags, remove white spaces foreach ($tags as $tag) { // if after trimming something remains if (trim($tag)) { $tagsFormatted[] = strtolower(trim($tag)); } } $allTagIds = []; // Loop over eah tag foreach ($tagsFormatted as $tag) { // Grab the first matching result or insert this new unique tag // if tag is present will not insert into db. If not present, inserts into db. $theTag = Tag::firstOrCreate(['name' => $tag]); $allTagIds[] = $theTag->id; } // Attach the tag ids to the tweet $newTweet->tags()->attach($allTagIds); return redirect('profile'); }
public function edit(Post $post) { $data['tags'] = Tag::lists('name', 'id'); $data['pages'] = Page::where('status', 1)->lists('title', 'id'); $data['post'] = $post; return view('post.update', $data); }
/** * Edit the channel * @param $id */ public function edit($id) { $channel = Channel::findOrFail($id); $tags = Tag::lists('name', 'id')->all(); $tag_list = $channel->tags->lists('name', 'id'); return view('channels.edit', compact('channel', 'tags', 'tag_list')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $post = Post::find($id); $tags = Tag::all(); $title = 'Editer une conférence'; return view('dashboard.edit', compact('post', 'tags', 'title')); }
public function edit($id) { $product = Product::find($id); $categories = Category::lists('title', 'id'); $tags = Tag::lists('name', 'id'); return view('admin.edit', compact('product', 'tags', 'categories')); }
/** * @return a post * @param $id */ public function showPostTag($id) { $tag = Tag::find($id); $posts = $tag->posts()->orderBy('date_start', 'DESC')->where('status', 'publish')->get(); $name = $tag->name; return view('front.tag', compact('posts', 'name')); }
public function search(Request $request) { $searchTerm = is_null($request->input('query')) ? "" : $request->input('query'); $city = is_null($request->input('city')) ? '' : $request->input('city'); $category = is_null($request->input('category')) ? "" : $request->input('category'); $participants = is_null($request->input('participants')) ? "" : $request->input('participants'); $min = is_null($request->input('min_budget')) ? 0 : $request->input('min_budget'); $max = is_null($request->input('max_budget')) ? 2147483647 : $request->input('max_budget'); $entries = Entry::where('title', 'LIKE', "%{$searchTerm}%")->where('city', 'LIKE', "%{$city}%")->where('address', 'LIKE', "%{$city}%")->where('categories', "LIKE", "%{$category}%")->where('participants', 'LIKE', "%{$participants}%")->where('budget', '>=', $min)->where('budget', '<=', $max)->with('days')->with('hours')->with('tags'); /*if($searchTerm != ''){ $entries = Entry::where('title','LIKE',"%$searchTerm%"); } else if($city != ''){ $entries = $entries->where('description','LIKE',"%$searchTerm%"); } else if($category != ''){ $entries = $entries->where('categories','LIKE',"%$categories%"); } else if($participants != ''){ $entries = $entries->where('participants','LIKE',""); }*/ $entries = $entries->get(); $tags = Tag::where('description', 'LIKE', "%{$searchTerm}%")->get(); foreach ($tags as $tag) { $entries->merge($tag->entry()->get()); } header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Credentials: true "); header("Access-Control-Allow-Methods: OPTIONS, GET, POST"); header("Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, \n X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control"); return $entries->toJson(); }
public static function boot() { parent::boot(); Tag::deleting(function ($tag) { $tag->stations()->detach(); }); }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Tag::create(['name' => $faker->word]); } }