Beispiel #1
0
 /**
  * Get time line by event ID
  *
  * @param int $id
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function getByEventId($id)
 {
     $time_line = new \Illuminate\Database\Eloquent\Collection();
     $get = self::where('events_time_line.event_id', (int) $id)->select('events_messages.message', 'events_comments.comment', 'events_comments.user_id', \DB::raw('concat(profiles.firstname, " ", profiles.lastname) as user_name'), 'profiles.avatar_url', 'events_time_line.id as time_line_id', 'events_time_line.time as time', 'events_time_line.type as type')->leftjoin('events_messages', 'events_messages.id', '=', 'events_time_line.message_id')->leftjoin('events_comments', 'events_comments.id', '=', 'events_time_line.comment_id')->leftjoin('profiles', 'profiles.user_id', '=', 'events_comments.user_id')->groupBy('events_time_line.id')->orderBy('events_time_line.id', 'desc')->get();
     foreach ($get as $row) {
         switch ($row->type) {
             case 'message':
                 $time_line->push(new Message($row));
                 break;
             case 'comment':
                 $time_line->push(new Comment($row));
                 break;
         }
     }
     return $time_line;
 }
 /**
  * @param array $overrides
  * @param int $amount
  *
  * @return \Hootlex\Moderation\Tests\Post
  */
 function createPost($overrides = [], $amount = 1)
 {
     $posts = new \Illuminate\Database\Eloquent\Collection();
     for ($i = 0; $i < $amount; $i++) {
         $post = Post::create(array_merge(['moderated_at' => 0], $overrides));
         $posts->push($post);
     }
     return count($posts) > 1 ? $posts : $posts[0];
 }
 /**
  * Admin view
  */
 public function index()
 {
     $initialCategories = Category::whereNull('parent_id')->with(['categories' => function ($query) {
         $query->orderBy('weight', 'desc')->orderBy('id');
     }])->orderBy('weight', 'desc')->orderBy('id')->paginate();
     $links = $initialCategories->links();
     $result = new \Illuminate\Database\Eloquent\Collection();
     $initialCategories->each(function ($category) use($result) {
         $result->push($category);
         $category->categories->each(function ($category) use($result) {
             $result->push($category);
         });
     });
     $result->load('parent');
     //		dd($result);
     return View::make('admin.dicts.list', ['title' => 'Категории', 'columns' => ['ID', 'Родитель', 'Вес', 'Заголовок', 'Описание', 'Под', 'Посты', 'Ком', 'посты', '', ''], 'data' => $result->transform(function ($category) use($links) {
         return ['id' => $category->id, 'parent_id' => $category->parent_id ? "{$category->parent->title} ({$category->parent_id})" : '', 'weight' => $category->weight . ' ' . link_to("admin/categories/{$category->id}/up", "&uarr;") . ' ' . link_to("admin/categories/{$category->id}/down", "&darr;"), 'title' => $category->title, 'description' => $category->description, 'subscriptions' => $category->subscriptions_count, 'posts_count' => $category->posts_count, 'comments' => $category->comments_count, 'posts' => link_to("/admin/categories/{$category->id}/posts", 'посты &rarr;'), 'edit' => link_to("/admin/categories/{$category->id}/edit", 'редактировать'), 'delete' => link_to("/admin/categories/{$category->id}/delete", 'удалить')];
     }), 'links' => $links, 'actions' => [['link' => '/admin/categories/create', 'text' => 'Добавить']]]);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function anyEdit($id = false)
 {
     $content = $this->content->with(array('template_setting', 'setting'))->findOrFail($id);
     //dd($content->setting);
     //$permission = Permission::getPermission('content', $content->id, 'w');
     //$allPermissions = Permission::getContentPermissions($id);
     $allPermissions = \Permission::getControllerPermission($id, \Route::currentRouteAction());
     //foreach template setting we want to add a setting for this row..
     //dd($content->template_setting);
     if (!empty($content->template_setting)) {
         //TODO: There has to be a cleaner way of doing this.
         $all_settings = new \Illuminate\Database\Eloquent\Collection();
         foreach ($content->template_setting as $template_setting) {
             $fl = $content->setting->filter(function ($setting) use($template_setting) {
                 return $template_setting->name === $setting->name;
             });
             if ($fl->count()) {
                 foreach ($fl as $f) {
                     //if it's fount int content_settings and template_settings, use
                     $all_settings->push($f);
                 }
             } else {
                 $all_settings->push($template_setting);
             }
         }
         foreach ($content->setting as $setting) {
             $fl = $content->template_setting->filter(function ($template_setting) use($setting) {
                 return $setting->name === $template_setting->name;
             });
             if ($fl->count() == 0) {
                 $all_settings->push($setting);
             }
         }
     }
     $settings = $all_settings->groupBy('section');
     //dd($content->edit_package);
     //dd($content->edit_service_provider);
     //App::register($content->edit_service_provider); //we need to register any additional sp.. incase we have some weird edit page.
     $content = \Content::setDefaults($content);
     //dd($content->edit_package.'::'.$content->edit_view);
     if (\Request::ajax()) {
         return $this->render($content->edit_view, compact('content', 'content_defaults', 'settings', 'allPermissions'));
     } else {
         $tree = $content->getDescendants(config('bootlegcms.cms_tree_descendents'));
         return $this->render('layouts.tree', compact('content', 'content_defaults', 'settings', 'allPermissions'));
     }
 }
 public function search()
 {
     $searchResults = new \Illuminate\Database\Eloquent\Collection();
     $string = Input::get('string');
     $productCategories = ProductCategory::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($productCategories as $productCategory) {
         $body = strip_tags($productCategory->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $productCategory->title, 'body' => $body, 'link' => '/catalog/' . $productCategory->id]);
         $searchResults->push($searchResult);
     }
     $productLines = ProductLine::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($productLines as $productLine) {
         $body = strip_tags($productLine->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $productLine->title, 'body' => $body, 'link' => '/productLine/' . $productLine->id]);
         $searchResults->push($searchResult);
     }
     $products = Product::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($products as $product) {
         $body = strip_tags($product->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $product->title, 'body' => $body, 'link' => '/product/' . $product->id]);
         $searchResults->push($searchResult);
     }
     $masterClasses = MasterClass::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($masterClasses as $masterClass) {
         $body = strip_tags($masterClass->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $masterClass->title, 'body' => $body, 'link' => '/master-class/' . $masterClass->id]);
         $searchResults->push($searchResult);
     }
     $events = Event::where('title', 'like', '%' . $string . '%')->orWhere('body', 'like', '%' . $string . '%')->get();
     foreach ($events as $event) {
         $body = strip_tags($event->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $event->title, 'body' => $body, 'link' => '/events/' . $event->id]);
         $searchResults->push($searchResult);
     }
     $novelties = Novelty::where('title', 'like', '%' . $string . '%')->orWhere('body', 'like', '%' . $string . '%')->get();
     foreach ($novelties as $novelty) {
         $body = strip_tags($novelty->description);
         if (strlen($body) > 100) {
             $body = mb_substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $novelty->title, 'body' => $body, 'link' => '/novelties/' . $novelty->id]);
         $searchResults->push($searchResult);
     }
     $reviews = Review::where('body', 'like', '%' . $string . '%')->get()->load('regionTechnology');
     foreach ($reviews as $review) {
         $body = strip_tags($review->body);
         if (strlen($body) > 100) {
             $body = mb_substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => RegionTechnology::where('id', $review->region_technology_id)->first()->username, 'body' => $body, 'link' => '/reviews/' . $review->id]);
         $searchResults->push($searchResult);
     }
     $competitions = Competition::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($competitions as $competition) {
         $body = strip_tags($competition->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $competition->title, 'body' => $body, 'link' => '/competitions/' . $competition->id]);
         $searchResults->push($searchResult);
     }
     $courses = Course::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($courses as $course) {
         $body = strip_tags($course->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $course->title, 'body' => $body, 'link' => '/courses/' . $course->id]);
         $searchResults->push($searchResult);
     }
     $massMediaNews = MassMediaNews::where('title', 'like', '%' . $string . '%')->orWhere('body', 'like', '%' . $string . '%')->get();
     foreach ($massMediaNews as $massMediaNewItem) {
         $body = strip_tags($massMediaNewItem->body);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $massMediaNewItem->title, 'body' => $body, 'link' => '/mass-media-news/' . $massMediaNewItem->id]);
         $searchResults->push($searchResult);
     }
     $regionWorkshops = RegionWorkshop::where('title', 'like', '%' . $string . '%')->orWhere('description', 'like', '%' . $string . '%')->get();
     foreach ($regionWorkshops as $regionWorkshop) {
         $body = strip_tags($regionWorkshop->description);
         if (strlen($body) > 100) {
             $body = substr($body, 0, 100);
         }
         $searchResult = new SearchResult(['title' => $regionWorkshop->title, 'body' => $body, 'link' => '/regions/workshops/' . $regionWorkshop->id]);
         $searchResults->push($searchResult);
     }
     return view('home.searchResults', ['string' => $string, 'searchResults' => $searchResults]);
 }
 public function search(Request $request)
 {
     // echo '<pre>';
     // var_dump($request->all());
     // return $request->input('date');
     $dates = Date::all();
     foreach ($dates as $date) {
         // var_dump($date->typeOfDate);
     }
     if ($request->input('type')) {
         $newDates = new \Illuminate\Database\Eloquent\Collection();
         switch ($request->input('type')) {
             case 'culinair':
                 foreach ($dates as $date) {
                     if ($date->typeOfDate == "1") {
                         $newDates->push($date);
                         // = $dates->where('typeOfDate', "1");
                     }
                 }
                 break;
             case 'romantic':
                 //$dates = $dates->where('typeOfDate', "2");
                 foreach ($dates as $date) {
                     // echo $date->id;
                     if ($date->typeOfDate == "2") {
                         // var_dump('romantic');
                         $newDates->push($date);
                         // = $dates->where('typeOfDate', "1");
                     }
                 }
                 break;
         }
         // var_dump($newDates);
         $dates = $newDates;
     }
     if ($request->input('date')) {
         $newDates = new \Illuminate\Database\Eloquent\Collection();
         foreach ($dates as $date) {
             // echo $date->date;
             if ($date->date == $request->input('date')) {
                 $newDates->push($date);
             }
         }
         $dates = $newDates;
     }
     if ($request->input('sex')) {
         $newDates = new \Illuminate\Database\Eloquent\Collection();
         foreach ($dates as $date) {
             if ($date->host->sex == $request->input('sex')) {
                 $newDates->push($date);
             }
         }
         $dates = $newDates;
     }
     foreach ($dates as $date) {
         // $date->host()->id;
         $date->host = $date->host()->first();
         $date->host->pic = $date->host->pictures()->first();
     }
     // var_dump($dates);
     return response()->json($dates);
     // $dates = Date::all();
     //
     // $data = ['dates' => $dates];
     //
     // var_dump($request->all());
     // // var_dump($dates);
     // return view('dates.search')->with($data);
 }