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()]; }
public function userPhotos() { $tags = Tag::where('id', '>', 0)->get(); $phototags = PhotoTag::where('image_id', '>', 0)->get(); $images = Image::where('user_id', '=', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(10); return view('user.photos')->with(['images' => $images, 'tags' => $tags, 'phototags' => $phototags]); }
/** * 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); }); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { //$member = Member::find($id); $profileUser = User::where('slug', $id)->first(); $member = Member::where('user_id', $profileUser->id)->first(); $user = Auth::user(); $isMemberProfile = false; $isFollowing = false; $showWelcomeMessage = false; if (Auth::check()) { if ($member->user_id == Auth::User()->id) { $isMemberProfile = true; if (!$user->welcomed) { $showWelcomeMessage = true; $user->welcomed = true; $user->save(); } } if (Follower::where('user_id', $member->user->id)->where('follower_id', $user->id)->count()) { $isFollowing = true; } } $artists = Artist::where('verified', true)->orderBy('firstname', 'asc')->get(); $categories = Tag::where('isCategory', true)->get(); return view('pages.member', ['member' => $member, 'isMemberProfile' => $isMemberProfile, 'isFollowing' => $isFollowing, 'artists' => $artists, 'categories' => $categories, 'showWelcomeMessage' => $showWelcomeMessage]); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); /*Route::model*/ /** * Route model binding altering default logic * $router->bind('articles',function($id){ * return \App\Article::published()->findOrFail($id); * }); */ /*Using wildcard*/ /*$router->model('articles','App\Article');*/ $router->bind('articles', function ($id) { return \App\Article::published()->findOrFail($id); }); $router->bind('rates', function ($id) { return \App\Rate::where('id', $id)->firstOrFail(); }); $router->bind('customers', function ($id) { return \App\Customer::where('id', $id)->firstOrFail(); }); $router->bind('tags', function ($name) { return \App\Tag::where('name', $name)->firstOrFail(); }); $router->bind('motherboards', function ($name) { return \App\Motherboard::where('name', $name)->firstOrFail(); }); }
public function tag($name) { $tag = \App\Tag::where('name', '=', $name)->firstOrFail(); $tags = \App\Tag::all(); $posts = $tag->posts; return view('frontend.pages.tag')->with('posts', $posts)->with('tags', $tags)->with('tag', $tag); }
/** * 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(); }); }
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(); }
/** * Edit a bookmark * @param Integer $id The bookmark_id of the bookmark * @return View A view for editing the bookmark */ public function getEdit($id) { $userID = Auth::user()->id; try { //Find the bookmark with ID=$id $bookmark = Bookmark::findOrFail($id); //Now find it's tags $tagsForBookmark = BookmarkTag::where('bookmark_id', $bookmark->bookmark_id)->get(); if (sizeof($tagsForBookmark) > 0) { $tagNames = []; foreach ($tagsForBookmark as $tagItem) { $tagName = Tag::where('tag_id', $tagItem->tag_id)->get()[0]->tag_name; $tagNames[] = $tagName; } $tags = $tagNames; } else { //Create a new PageContentParser with the bookmark's content $contentParser = new PageContentParser($bookmark->content); //Get 5 suggested tags $tags = $contentParser->getTags(5); } $data = ['bookmark' => $bookmark, 'userID' => $userID, 'tags' => implode(",", $tags)]; return view('bookmark/edit-bookmark')->with($data); } catch (ModelNotFoundException $e) { return "Bookmark not found: " . $e->getMessage(); } }
/** * 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('tags', function ($name) { return \App\Tag::where('name', $name)->firstOrFail(); }); }
public function getEdit($id) { $site = Site::find($id); $site->labels = explode(',', $site->keywords); $tag = Tag::find($site->tag_id); $tags = Tag::where('user_id', '=', Auth::id())->get(); return view('site.edit', compact('site', 'tag', 'tags')); }
public function gettag(Request $request) { if (Auth::check()) { $tag = Tag::where('id', $request->input('id'))->get()->first(); $articles = $tag->articles()->where('article_uid', Auth::id())->orderBy('updated_at', 'desc')->simplePaginate(20); return view('tag', ['articles' => $articles, 'tag' => $tag]); } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($slug) { $tag = Tag::where('slug', $slug)->firstOrFail(); $posts = Post::with('tags')->whereHas('tags', function ($q) use($tag) { $q->where('tag_id', $tag->id); })->orderBy('created_at', 'desc')->paginate(15); return view('tags.show', compact('tag', 'posts')); }
public function articlesbytag($id) { $choosenLang = \Session::get('locale'); $tags = Tag::where('lang', '=', $choosenLang)->get(); $tag = Tag::findOrFail($id); $articles = $tag->articles()->paginate(2); return view('index', compact('articles', 'tags')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($slug) { $tag = Tag::where('slug', $slug)->first(); $articles = $tag->articles()->get(); $tags = Tag::all(); $categories = Category::all(); return view('articles.tags.show', compact('articles', 'categories', 'tags')); }
public function show($tag) { $tags = Tag::where('name', $tag)->firstOrFail(); // dd($tags); $articles = $tags->articles()->published()->get(); //dd($art); return view('articles.index', compact('articles')); }
public function edit(SkillRepository $skillRepository, Skill $skill) { $categories = Category::where('parent_id', null)->lists('name', 'id'); $sub_categories = Category::findOrFail($skill->sub_category_id)->getSiblingsAndSelf()->lists('name', 'id'); $all_tags = Tag::where('parent_id', $skill->sub_category_id)->lists('name', 'id'); $my_rate = $skillRepository->my_rate(); $statuses = $skillRepository->statuses(); return view('profile.newSkill', compact('categories', 'my_rate', 'skill', 'sub_categories', 'all_tags', 'statuses'))->with(['title' => 'ثبت مهارت جدید', 'new_skill' => 1, 'edit_skill' => 0, 'step' => 1, 'hasEdit' => 1]); }
public function delete(Request $request) { $tag = \App\Tag::where('id', '=', $request->get('name'))->first(); if (!is_null($tag)) { $tag->delete(); } $ret = array('result' => 'success', 'message' => 'The Tag ' . $tag->name . ' is removed successfully'); return \Response::json($ret); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); // $router->model('name', 'App\Tag'); $router->bind('tags', function ($tags) { return \App\Tag::where('name', $tags)->firstOrFail(); }); }
/** * Display a listing of the resource. * * @return Response */ public function index() { if (Request::get('filter')) { $records = Tag::where('title', 'LIKE', '%' . Request::get('filter') . '%')->paginate(10); } else { $records = Tag::paginate(10); } return view('back::scope.blog.tags.index', compact('records')); }
public function syncTags(array $tags) { Tag::addNeededTags($tags); if (count($tags)) { $this->tags()->sync(Tag::where('user_id', Auth::user()->id)->whereIn('title', $tags)->lists('id')->all()); return; } $this->tags()->detach(); }
public function step1(Shop $shop, Product $product) { $user = Auth::user(); $skills = $user->skills()->lists('title', 'id'); $sub_categories = Category::findOrFail($product->category_id)->getSiblingsAndSelf()->lists('name', 'id'); $main_categories = Category::where('parent_id', null)->lists('name', 'id'); $product['main_category'] = Category::findOrFail($product->category_id)->getRoot()->id; $all_tags = Tag::where('parent_id', $product->category_id)->lists('name', 'id'); return view('store.shop.product.create', compact('shop', 'product', 'skills', 'main_categories', 'sub_categories', 'all_tags'))->with(['title' => 'ثبت محصول جدید', 'for' => 'edit']); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); //pas sure si besoin ligne juste en bas $router->model('torrents', 'App\\Torrent'); $router->bind('tags', function ($name) { return \App\Tag::where('name', $name)->firstOrFail(); }); }
/** * 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('recipes', function ($id) { return \App\Recipe::published()->findOrFail($id); }); $router->bind('tags', function ($name) { return \App\Tag::where('name', $name)->firstOrFail(); }); }
/** * 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) { return Article::published()->findOrFail($id); }); $router->bind('tags', function ($name) { return Tag::where('name', $name)->first(); }); }
/** * 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) { return \Route::currentRouteName() == "articles.edit" ? \App\Article::findOrFail($id) : \App\Article::published()->findOrFail($id); }); $router->bind('tags', function ($name) { return \App\Tag::where('name', $name)->firstOrFail(); }); }
/** * Return data for a tag index page * * @param string $tag * @return array */ protected function tagIndexData($tag) { $tag = Tag::where('tag', $tag)->firstOrFail(); $reverse_direction = (bool) $tag->reverse_direction; $posts = Post::where('published_at', '<=', Carbon::now())->whereHas('tags', function ($q) use($tag) { $q->where('tag', '=', $tag->tag); })->where('is_draft', 0)->orderBy('published_at', $reverse_direction ? 'asc' : 'desc')->simplePaginate(config('blog.posts_per_page')); $posts->addQuery('tag', $tag->tag); $page_image = $tag->page_image ?: config('blog.page_image'); return ['title' => $tag->title, 'subtitle' => $tag->subtitle, 'posts' => $posts, 'page_image' => $page_image, 'tag' => $tag, 'reverse_direction' => $reverse_direction, 'meta_description' => $tag->meta_description ?: config('blog.description')]; }
public function show($tag) { $rs = Tag::where('tag', $tag)->get(); $arr = array(); foreach ($rs as $v) { array_push($arr, $v->article_id); } $articles = Article::whereIn('id', $arr)->get(); $tags = Tag::select('tag')->distinct()->get(); return view('member.tags.show', compact('tag', 'tags', 'articles')); }
/** * Run the database seeds. * * @return void */ public function run() { $books = ['screen cast' => ['php', 'html', 'css', 'mysql'], 'pdf cast' => ['php', 'html', 'css', 'js'], 'flash cast' => ['forms', 'front-end', 'css', 'js']]; foreach ($books as $title => $tags) { $book = \App\Book::where('title', 'like', $title)->first(); foreach ($tags as $tagName) { $tag = \App\Tag::where('name', 'LIKE', $tagName)->first(); $book->tags()->save($tag); } } }
/** * Run the database seeds. * * @return void */ public function run() { $books = ['1.mp4' => ['mysql', 'security', 'php', 'model'], '2.mp4' => ['mysql', 'security', 'php', 'controller'], '3.mp4' => ['ui', 'nonfiction', 'js', 'view'], '4.mp4' => ['mysql', 'ui', 'html', 'css']]; foreach ($books as $title => $tags) { $book = \App\Book::where('title', 'like', $title)->first(); foreach ($tags as $tagName) { $tag = \App\Tag::where('name', 'LIKE', $tagName)->first(); $book->tags()->save($tag); } } }