public function __construct() { $this->bannersSelect = Content::where('type', 'Banners')->get(); $this->galleriesSelect = Content::where('type', 'Galleries')->get(); $this->linksSelect = Content::where('type', 'Links')->get(); $this->peopleSelect = Content::where('type', 'People')->get(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($type) { if ($type) { $content = Content::where('type', '=', $type)->orderBy('id', 'desc')->get(); } return view('admin/content/index', ['content' => $content, 'type' => $type]); }
public function home() { // get all site content $contents = Content::where('published', '=', true)->orderBy('id', 'desc')->with('type', 'columns', 'columns.type', 'tags', 'categories', 'assets', 'assets.source')->whereNotNull('content_type_id')->get(); $contents = $this->transformer->collection($contents); return view('pages.home', compact('contents')); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $social = Content::where('title', 'Sosyal Medya')->first(); $this->socials = $social != NULL ? $social->links()->get() : NULL; view()->share('socials', $this->socials); return $next($request); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // $type = ucfirst(\Request::segment(2)); $contents = Content::where('type', $type)->get(); return view('admin.content.index')->with(['contents' => $contents]); }
/** * Display a listing of the resource. * * @return Response */ public function index($url) { $content = Content::where('url', '=', $url)->first(); if (!$content) { abort(404); } return view('content.custom', compact('content')); }
public function getAll($subtopic_name) { $me = SubTopic::where('name', $subtopic_name)->get()->toArray(); $arr = $me[0]; $subtopic_code = $arr["subtopic_code"]; $content = Content::where('subtopic_code', $subtopic_code)->get(); return view('sources')->with(['allcontent' => $content, 'subtopic_name' => $subtopic_name]); }
public function showGalleries(Request $r) { $hc = new HomeController(); $vars = $hc->getVars(); $lang = $r->session()->get("lang", "fa"); $galleries = Content::where("type", "galleries")->get(); return view('galleries', ["galleries" => $galleries, "lang" => $lang, "vars" => $vars]); }
public function getRelatedBlog($id) { $ids = DB::select('call related(?)', array($id)); if (count($ids) < 3) { return Content::where("type", "blogs")->orWhere("type", "didactics")->take(3)->get(); } return Content::find([$ids[0]->content_id, $ids[1]->content_id, $ids[2]->content_id]); }
public function haberci($account, $slug) { $iletisim = \App\Host::where('subdomain', $account)->first(); $contact = \App\User::find($iletisim->user_id)->contact; $about = \App\User::find($iletisim->user_id)->about; $sliders = \App\User::find($iletisim->user_id)->slider; $haber = \App\Content::where('alias', $slug)->where('user_id', $iletisim->user_id)->first(); return view('frontend.haber', compact('contact', 'about', 'sliders', 'haber')); }
public function index($content_name) { $content = Content::find(id_from_name($content_name)); $recommends = Content::where('id', '!=', $content->id)->where('recommend', 1)->take(config('app.frontEnd.content.recommend_show'))->get(); if (count($recommends) === 0) { $recommends = Content::where('id', '!=', $content->id)->orderByRaw("RAND()")->take(config('app.frontEnd.content.recommend_show'))->get(); } return view('detail', ['adsCategories' => AdsCatg::all(), 'category_menus' => Category::all(), 'content' => $content, 'date' => new Carbon(), 'recomend_contents' => $recommends, 'user' => Auth::user()]); }
public function search($tag) { $tuple = SubTopic::where('tags', $tag)->get()->toArray(); if ($tuple == null) { return view('search')->with('message', 'not found'); } $tuple = $tuple[0]; $subtopic_code = $tuple['subtopic_code']; dd($subtopic_code); $sources = Content::where('subtopic_code', $subtopic_code)->get()->toArray(); return view('search')->with('message', $sources); }
public function search(Request $request) { $menu = \App\Menu::find(1); $search = $request->input('search') ?: ''; /*$categories = \App\Category::where('level','1')->orderBy('ordering')->get(); $parentCategory = \App\Category::where('title','like','%'.$search.'%') ->orWhereIn('parent_id',DB::table('categories')->where('title',$search)->lists('id')) ->lists('id');*/ $categories = \App\Category::whereNull('deleted_at')->get(); $contents = \App\Content::where('title', 'like', '%' . $search . '%')->whereNull('deleted_at')->orderBy('created_at')->paginate(21); return view('project_list')->with(['category' => '', 'categories' => $categories, 'contents' => $contents, 'menu' => $menu]); }
public function json(Request $requests) { $limit = $requests->input('limit') ? $requests->input('limit') : 15; if ($limit > 100 || $limit <= 0) { $limit = 15; } $contents = Content::where('title', 'like', '%' . $requests->input('search') . '%')->orderBy('created_at', 'desc')->paginate($limit); $data = View('admin.contents.content_template')->with('contents', $contents)->render(); return response()->json($data); /*return response()->json([ 'DATA' => $contents->toJson(), 'PAGINATION' => $contents->render() ]);*/ }
public function search(Request $r) { $lang = $r->session()->get("lang", "fa"); $query = $r->input("query"); if (strlen($query) < 2) { return view("error", ["messega" => "Search Query must be at least 2 characters"]); } $result = Content::where("title", "like", "%" . $query . "%")->get(); $types = array(); foreach ($result as $res) { $types[$res->type] = $res->farsiType(); } array_unique($types); $var = $this->getVars(); return view("searchresult", ["query" => $query, "result" => $result, "types" => $types, "lang" => $lang, "vars" => $var]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $main_page = Content::where('type', '=', 'mainpage')->get()->first(); $main_page_arr = []; if (isset($main_page) && $main_page->count()) { $main_page_arr = $main_page->toArray(); } if (is_array($main_page_arr) && isset($main_page_arr['text']) && trim($main_page_arr['text']) == '') { $main_page_arr['text'] = '<h1>Приносим свои извинения, страница находится в разработке.</h1>'; } if (is_array($main_page_arr) && isset($main_page_arr['title']) && trim($main_page_arr['title']) == '') { $main_page_arr['title'] = 'Сайт компании Golden Motors'; } $main_slider = UIComponents::where('name', '=', 'main-slider')->get()->first(); $main_slider_arr = []; if (isset($main_slider) && isset($main_slider->obj)) { $obj = json_decode($main_slider->obj); if (isset($obj->images)) { $main_slider_arr['images'] = $obj->images; } if (isset($obj->html)) { $main_slider_arr['html'] = $obj->html; } if (isset($obj->html)) { $main_slider_arr['configuration'] = $obj->configuration; } } $partners_slider = UIComponents::where('name', '=', 'partners-slider')->get()->first(); $partners_slider_arr = []; if (isset($partners_slider) && isset($partners_slider->obj)) { $obj = json_decode($partners_slider->obj); if (isset($obj->images)) { $partners_slider_arr['images'] = $obj->images; } if (isset($obj->html)) { $partners_slider_arr['html'] = $obj->html; } if (isset($obj->configuration)) { $partners_slider_arr['configuration'] = $obj->configuration; } } $feedbacks_arr = Content::getContent('feedback', 0); return view('catalog/index/index', ['mainpage' => $main_page_arr, 'main_slider' => $main_slider_arr, 'partners_slider' => $partners_slider_arr, 'feedbacks' => $feedbacks_arr]); }
static function getLastContent($type, $limit) { $content_roots = Content::where('type', '=', $type)->where('parent_id', '=', 0)->where('published', '=', 1)->get(); $content_arr_with_images = []; if (isset($content_roots) && $content_roots->count()) { $content_roots_arr = $content_roots->toArray(); if (isset($content_roots_arr) && is_array($content_roots_arr) && count($content_roots_arr)) { $content_arr = []; $root = new Content(); foreach ($content_roots_arr as $root_arr) { $content_arr = array_merge($content_arr, $root->buildCategoriesContent($type, $root_arr['id'])); } if (isset($content_arr) && is_array($content_arr) && count($content_arr)) { $content_pages_arr = []; foreach ($content_arr as $element) { $content_pages_arr[$element['id']] = $element; } krsort($content_pages_arr); $i = 0; $c_arr = []; foreach ($content_pages_arr as $content_page) { if ($i < $limit && $content_page['published'] == 1) { $c_arr[] = $content_page; $i++; } } } } if (isset($c_arr) && is_array($c_arr)) { $content_obj = new Content(); $content_arr_with_date = $content_obj->convertDate($c_arr); $content_arr_with_images = $content_obj->addPreviewImages($content_arr_with_date); } } return $content_arr_with_images; }
public function report(\Illuminate\Http\Request $request) { // $request->likeValue; $cont = Content::find($request->contentId); Content::where('id', '=', $request->contentId)->update(['redflag' => $cont->redflag + $request->reportValue]); if ($request->reportValue == 1) { Content::where('id', '=', $request->contentId)->update(['pscore' => $cont->pscore - 20]); } else { Content::where('id', '=', $request->contentId)->update(['pscore' => $cont->pscore + 20]); } if (Auth::user()) { if ($request->reportValue == 1) { Auth::user()->update(['mplaypoints' => Auth::user()->mplaypoints + 20]); Auth::user()->update(['loyaltypoints' => Auth::user()->loyaltypoints + 20]); } else { Auth::user()->update(['mplaypoints' => Auth::user()->mplaypoints - 20]); Auth::user()->update(['loyaltypoints' => Auth::user()->loyaltypoints - 20]); } $userAction = Useraction::where('userid', '=', Auth::user()->id)->where('crefid', '=', $request->contentId)->where('actiontype', '=', 'Flag')->orWhere('actiontype', '=', 'Unflag')->get(); // return $userAction; if (!$userAction->isEmpty()) { $newActionType = ""; if ($userAction[0]->actiontype == "Flag") { $newActionType = "Unflag"; } else { $newActionType = "Flag"; } Useraction::where('id', '=', $userAction[0]->id)->update(['actiontype' => $newActionType]); } else { $userAction = new Useraction(); $userAction->crefid = $request->contentId; $userAction->actiontype = "Flag"; $userAction->creftype = "M"; $userAction->userid = Auth::user()->id; $userAction->save(); return $userAction; } // Auth::user()->action()->save($userAction); } }
public function show() { //Kullanıcı bazlı haber çekme return Content::where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->get(); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Requests\CreateArticleRequest $request, $id) { if (\Auth::check() == false) { return redirect('/auth/login'); } $articles = Article::findOrFail($id)->update(['publish_date' => time()]); #$articles->update($request->all()); // 更新到content表中 $contentArr = ['article_id' => $id, 'content' => $request->content]; //dd($contentArr); $content = Content::where('article_id', $id)->update($contentArr); //dd($content); #$content->update($contentArr); return redirect('/articles/'); }
public function index($category_name) { $category_id = Category::where('name', $category_name)->first()->id; $contents = Content::where('category_id', $category_id)->where('status', 'approve')->paginate(config('app.frontEnd.content.per_page')); return view('category', ['adsCategories' => AdsCatg::all(), 'category_menus' => Category::all(), 'contents' => $contents, 'user' => Auth::user()]); }
public function blog_category($pseudo_url) { $content = Content::where('pseudo_url', '=', $pseudo_url)->get()->first(); $blog_pages = Content::getContent('blog', $content->id); $categories = Content::getCategories('blog'); return view('catalog/content/blog/index', ['content' => $content, 'blog_pages' => $blog_pages, 'categories' => $categories, 'active_category_id' => $content->id]); }
public function showBySubTopicId($subtopic_code) { $content = Content::where('subtopic_code', $subtopic_code)->get(); return response()->json(['error' => false, 'content' => $content]); }
public function getAdminTable(Request $r) { $items = array(); $query = $r->input("query", ""); $sort = $r->input("sort", "id"); $asc = "DESC"; if ($sort == "old" || $sort == "title") { $asc = "ASC"; } if ($sort != "title") { $sort = "id"; } switch ($r->input("entity")) { case "contents": $items = Content::where("type", $r->input("type"))->where("title", "like", "%" . $query . "%")->orderBy($sort, $asc)->simplePaginate(10); break; case "members": $items = Member::where("firstname", "like", "%" . $query . "%")->orWhere("lastname", "like", "%" . $query . "%")->orderBy($sort, $asc)->simplePaginate(10); break; case "variables": $items = Variable::where("title", "like", "%" . $query . "%")->orderBy($sort, $asc)->simplePaginate(10); break; case "tags": $items = Tag::where("title", "like", "%" . $query . "%")->orderBy($sort, $asc)->simplePaginate(20); break; case "categories": $catcon = new CategoryController(); $items = $catcon->getTree(); break; default: echo "unknown type"; } return view('admintable', ['type' => $r->input('type'), 'entity' => $r->input('entity'), 'items' => $items]); }
$category = \App\Category::find($categoryId); $categories = \App\Category::where('level', '1')->where('parent_id', $menu->internal_url)->whereNull('deleted_at')->orderBy('ordering')->get(); if ($projectId == '') { $parentCategory = \App\Category::where('parent_id', $categoryId)->orWhereIn('parent_id', DB::table('categories')->where('parent_id', $categoryId)->whereNull('deleted_at')->lists('id'))->whereNull('deleted_at')->lists('id'); $parentCategorySup = \App\Category::whereNull('deleted_at')->where('parent_id', 'in', implode(' ,', $parentCategory->toArray()))->lists('id'); $contents = \App\Content::where('category_id', $categoryId)->orWhereIn('category_id', $parentCategory->toArray())->whereNull('deleted_at')->orderBy('created_at')->paginate(21); return view('project_list')->with(['category' => $category, 'categories' => $categories, 'contents' => $contents, 'menu' => $menu]); } else { $content = \App\Content::find($projectId); return view('project_info')->with(['category' => $category, 'categories' => $categories, 'content' => $content, 'menu' => $menu]); } })->where(['menuId' => '[0-9]+', 'categoryId' => '[0-9]+', 'projectId' => '[0-9]+']); Route::get('categories/projects/search', 'CategoryController@search'); Route::post('menu/{menuId}/categories/{categoryId}/projects', function ($menuId, $categoryId) { $parentCategory = \App\Category::where('parent_id', $categoryId)->orWhereIn('parent_id', DB::table('categories')->where('parent_id', $categoryId)->lists('id'))->whereNull('deleted_at')->lists('id'); $contents = \App\Content::where('category_id', $categoryId)->orWhereIn('category_id', $parentCategory->toArray())->whereNull('deleted_at')->orderBy('created_at')->paginate(21); $data = View('project_list_template')->with(['contents' => $contents, 'menu' => \App\Menu::find($menuId)])->render(); return response()->json($data); }); Route::get('locale/{locale?}', ['as' => 'locale.setocale', 'uses' => 'LocaleController@setLocale']); }); Route::get('/admin/login', function () { return view('login'); }); Route::get('admin/users/change_password', ['middleware' => ['auth'], 'uses' => 'Admin\\UserController@changePassword']); Route::get('admin', ['middleware' => ['auth'], 'uses' => 'Admin\\DashboardController@Index']); Route::get('admin/dashboard', ['middleware' => ['auth'], 'uses' => 'Admin\\DashboardController@Index']); Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => 'auth'], function () { Route::post('categories/updatecategory', 'CategoryController@UpdateCategory'); Route::post('categories/translation', 'CategoryController@Translation'); Route::resource('categories', 'CategoryController');
public function more(\Illuminate\Http\Request $request) { $tagname = $request->tagname; $limit = $request->limit; $offset = $request->offset; if ($tagname == "Posts") { // return $offset; $cont = Content::where('userid', '=', Auth::user()->id)->where('isvisible', '=', '1')->take($limit)->skip($offset)->get(); // $cont[0]->like=1; // return $cont; $id = 0; $cont[$id]->like = -1; $cont[$id]->comment = -1; $cont[$id]->report = -1; foreach ($cont as $c) { // use any of 2 methods both works // $userActions = Useraction::whereRaw('userid = ? and crefid = ?',[Auth::user()->id,$c->id])->get(); $userActions = Useraction::where('userid', '=', Auth::user()->id)->where('crefid', '=', $c->id)->get(); foreach ($userActions as $u) { if ($u->actiontype == "Like") { $cont[$id]->like = 1; } if ($u->actiontype == "Comment") { $cont[$id]->comment = 1; } if ($u->actiontype == "Flag") { $cont[$id]->report = 1; } } $id++; } } elseif ($tagname == "Comments") { $commentsAction = Useraction::where('userid', '=', Auth::user()->id)->where('actiontype', '=', "Comment")->groupBy('crefid')->take($limit)->skip($offset)->get(); // return $commentsAction; $k = 0; foreach ($commentsAction as $com) { $comments[$k] = Content::where('id', '=', $com->crefid)->where('isvisible', '=', '1')->first(); if ($comments[$k] != "") { $comments[$k]->comment = 1; $comments[$k]->like = -1; $comments[$k]->report = -1; if (!Useraction::where('crefid', '=', $com->crefid)->where('actiontype', '=', "Like")->get()->isEmpty()) { $comments[$k]->like = 1; } if (!Useraction::where('crefid', '=', $com->crefid)->where('actiontype', '=', "Flag")->get()->isEmpty()) { $comments[$k]->report = 1; } $k++; } } $cont = $comments; // return "limit=".$limit." offset=".$offset; } elseif ($tagname == "Favourites") { $favouritesAction = Useraction::where('userid', '=', Auth::user()->id)->where('actiontype', '=', "Like")->take($limit)->skip($offset)->get(); $j = 0; foreach ($favouritesAction as $f) { $fav[$j] = Content::where('id', '=', $f->crefid)->where('isvisible', '=', '1')->first(); if ($fav[$j] = "") { $fav[$j]->like = 1; $fav[$j]->comment = -1; $fav[$j]->report = -1; // $hasCommented=; if (!Useraction::where('crefid', '=', $f->crefid)->where('actiontype', '=', "Comment")->groupBy('crefid')->get()->isEmpty()) { $fav[$j]->comment = 1; } if (!Useraction::where('crefid', '=', $f->crefid)->where('actiontype', '=', "Flag")->groupBy('crefid')->get()->isEmpty()) { $fav[$j]->report = 1; } $j++; } } $cont = $fav; } // return $cont; return View::make('user.moreContent', compact('cont')); }
/** * Return all the posts as $url => $date */ protected function getPostsInfo() { return Content::where('publish_up', '<=', Carbon::now()->addHour(3))->orderBy('publish_up', 'title')->select('updated_at', 'alias')->get()->toArray(); }
public function searchContent(Request $request) { $contents = Content::where('name', 'like', '%' . spaceToLike($request->input('key_word')) . '%')->paginate(config('app.frontEnd.content.per_page')); return view('searchContent', ['adsCategories' => AdsCatg::all(), 'category_menus' => Category::all(), 'contents' => $contents, 'keyword' => $request->input('key_word'), 'user' => Auth::user()]); }
public function showDetail($id) { $contents = Content::where('id', $id)->get(); $currentid = Content::find($id)->id; $comments = DB::table('comments')->where('content_id', $currentid)->select('id', 'username', 'comment')->orderBy('comments.created_at', 'desc')->get(); $count = DB::table('comments')->where('content_id', $currentid)->select('id', 'username', 'comment')->orderBy('comments.created_at', 'desc')->count(); return view('content.show')->with('contents', $contents)->with('comments', $comments)->with('count', $count); }
| | Here is where you will register all of the routes in an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::group(['domain' => 'www.' . config('settings.domain')], function () { Route::get('/', 'Site\\MainController@index'); }); Route::group(['domain' => '{id}.' . config('settings.domain')], function () { Route::get('/', function ($id) { if (Cache::has($id)) { $detail = Cache::get($id); } else { try { $detail = \App\Content::where('seo', $id)->firstOrFail(); Cache::put($id, $detail, 15); } catch (ModelNotFoundException $e) { return redirect('/'); } } return view('Site.detail', ['content' => $detail, 'popular' => \App\Layout::popular()]); }); }); Route::get('/', function () { return redirect('http://www.' . config('settings.domain')); }); /* Route::group(['middleware' => ['web']], function () { Route::get('/', 'Site\MainController@index');