Exemplo n.º 1
0
 public function index()
 {
     // create new sitemap object
     $sitemap = App::make("sitemap");
     // set cache key (string), duration in minutes (Carbon|Datetime|int), turn on/off (boolean)
     // by default cache is disabled
     $sitemap->setCache('laravel.sitemap', 60);
     // check if there is cached sitemap and build new only if is not
     if (!$sitemap->isCached()) {
         // add item to the sitemap (url, date, priority, freq)
         $sitemap->add(url('about'), Carbon::createFromDate(2016, 7, 15), '0.3', 'monthly');
         $sitemap->add(url('privacy'), Carbon::createFromDate(2016, 7, 15), '0.3', 'monthly');
         $sitemap->add(url('terms'), Carbon::createFromDate(2016, 7, 15), '0.3', 'monthly');
         $designers = Designer::orderBy('created_at', 'desc')->get();
         foreach ($designers as $designer) {
             $sitemap->add($designer->url, $designer->updated_at, 0.8, 'daily');
         }
         $places = Place::orderBy('created_at', 'desc')->get();
         foreach ($places as $place) {
             $sitemap->add($place->url, $place->updated_at, 0.8, 'daily');
         }
         $stories = Story::orderBy('created_at', 'desc')->get();
         foreach ($stories as $story) {
             $sitemap->add($story->url, $story->updated_at, 0.8, 'daily');
         }
         $tags = Tag::orderBy('created_at', 'desc')->get();
         foreach ($tags as $tag) {
             $sitemap->add($tag->url, $tag->updated_at, 0.8, 'weekly');
         }
     }
     // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
     return $sitemap->render('xml');
 }
Exemplo n.º 2
0
 /**
  * Show the home page.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $designers = Designer::orderBy('id', 'desc')->take(9)->get();
     $places = Place::orderBy('id', 'desc')->take(9)->get();
     $stories = Story::whereHas('translations', function ($sub_query) {
         $sub_query->whereIn('locale', ['en', App::getLocale()])->whereNotNull('title')->whereNotNull('content');
     })->orderBy('id', 'desc')->take(9)->get();
     $tags = Tag::orderByRaw('RAND()')->take(9)->get();
     return view('pages.home', ['designers' => $designers, 'places' => $places, 'stories' => $stories, 'tags' => $tags]);
 }
Exemplo n.º 3
0
 /**
  * About us page
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function about(Request $request)
 {
     $data['designer_number'] = Designer::count();
     $data['design_number'] = Design::count();
     $data['place_number'] = Place::count();
     $data['story_number'] = Story::count();
     $data['tag_number'] = Tag::count();
     $data['user_number'] = User::count();
     $data['city_number'] = City::has('places')->orHas('designers')->count();
     return view('pages.about', $data);
 }
Exemplo n.º 4
0
 public function index(Page $page)
 {
     $designers = Designer::paginate();
     return view('pages.designers', ['page' => $page, 'designers' => $designers]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     $this->validate($request, ['action' => 'string|in:delete,restore,force_delete']);
     $designer = Designer::withTrashed()->find($id);
     if (empty($designer)) {
         abort(404);
     }
     if ($request->user()->cannot('delete-designer', $designer)) {
         abort(403);
     }
     switch ($request->input('action')) {
         case 'restore':
             $designer->restoreWithRelationships();
             break;
         case 'force_delete':
             $designer->forceDeleteWithRelationships();
             break;
         default:
             $designer->deleteWithRelationships();
     }
 }