/**
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function index()
 {
     $request = request();
     $name = $request->has('name') ? $request->get('name') : '';
     $sponsors = Sponsor::where(function ($query) use($name) {
         if (!empty($name)) {
             $query->where('name', 'LIKE', "%{$name}%");
         }
     })->paginate(env('LIMIT', 15));
     return view('sponsors.index', compact('sponsors', 'name'));
 }
 /**
  * Show the Project view page. (BY ANDREI)
  *
  * @return project_tbl data, date, amount
  */
 public function show($slug)
 {
     // fetch data according to slug
     $project = $slug;
     $logos = Sponsor::where('active', 1)->get();
     // find the Users Favourites and catch them
     $favourites = Favourite::all()->where('user_id', Session::get('userId'))->where('project_id', $project->id);
     //dd($favourites);
     // convert DB date into european date format
     $finish_date = date("d-m-Y", strtotime($project->completed_on));
     // convert DB amounts into european currency format
     $amount_raised = number_format($project->amount_raised, 2, ',', '.');
     $target_amount = number_format($project->target_amount, 2, ',', '.');
     $galleryImages = \App\Image::where('project_id', $project->id)->get();
     return view('pages.projectpage', compact('project', 'logos', 'finish_date', 'amount_raised', 'target_amount', 'galleryImages', 'favourites'));
 }
 public function relistSponsor($sponsorId)
 {
     $sponsor = Sponsor::where('id', $sponsorId)->update(['active' => 1]);
     return redirect()->back();
 }
    private function createSpecialEvents()
    {
        //NSBreakfast May
        $nsBreakfastMay = Carbon::create(2016, 5, 6, 8, 0, 0, new \DateTimeZone('Australia/Melbourne'));
        $nsBreakfastMay->setTimezone(new \DateTimeZone('UTC'));
        // using slug as a unique string identifier
        $slug = Str::slug(Event::SPECIAL . " {$nsBreakfastMay}");
        $this->info("Special Event (NSBreakfast) {$nsBreakfastMay} UTC");
        $event = Event::firstOrNew(['slug' => $slug]);
        $event->type = Event::SPECIAL;
        $event->slug = $slug;
        $event->title = 'NSBreakfast';
        $event->subtitle = 'Informal and unstructured; Hang out, drink coffee, eat breakfast and chat iOS / OSX';
        $event->starts_at = $nsBreakfastMay;
        $event->ends_at = $nsBreakfastMay->copy()->addHours(2);
        $event->contact = 'https://twitter.com/nsbreakfast';
        $event->contact_name = 'Matt Delves';
        $event->location = '1000 £ Bend';
        $event->location_link = 'http://thousandpoundbend.com.au';
        $event->address_display = '361 Little Lonsdale St, Melbourne';
        $event->address = '361 Little Lonsdale St, Melbourne, VIC 3000';
        $event->lat = -37.811672;
        $event->lng = 144.959092;
        $event->save();
        //NSBreakfast June
        $nsBreakfastJune = Carbon::create(2016, 6, 3, 7, 30, 0, new \DateTimeZone('Australia/Melbourne'));
        $nsBreakfastJune->setTimezone(new \DateTimeZone('UTC'));
        $slug = Str::slug(Event::SPECIAL . " {$nsBreakfastJune}");
        $this->info("Special Event (NSBreakfast) {$nsBreakfastJune} UTC");
        $event = Event::firstOrNew(['slug' => $slug]);
        $event->type = Event::SPECIAL;
        $event->slug = $slug;
        $event->title = 'NSBreakfast';
        $event->subtitle = 'Informal and unstructured; Hang out, drink coffee, eat breakfast and chat iOS / OSX';
        $event->starts_at = $nsBreakfastJune;
        $event->ends_at = $nsBreakfastJune->copy()->addHours(2);
        $event->contact = 'https://twitter.com/nsbreakfast';
        $event->contact_name = 'Matt Delves';
        $event->location = 'Hash Specialty Coffee';
        $event->location_link = 'http://facebook.com/hashcoffeeroasters';
        $event->address_display = '113 Hardware St, Melbourne';
        $event->address = '113 Hardware St, Melbourne, VIC 3000';
        $event->lat = -37.8123025;
        $event->lng = 144.9605897;
        $event->save();
        //WWDC Event June 2016
        $wwdcEventJune2016 = Carbon::create(2016, 6, 16, 18, 30, 0, new \DateTimeZone('Australia/Melbourne'));
        $wwdcEventJune2016->setTimezone(new \DateTimeZone('UTC'));
        $slug = Str::slug(Event::SPECIAL . " {$wwdcEventJune2016}");
        $this->info("Special Event (WWDC) {$wwdcEventJune2016} UTC");
        $event = Event::firstOrNew(['slug' => $slug]);
        $event->type = Event::SPECIAL;
        $event->slug = $slug;
        $event->title = 'Cocoaheads WWDC Special Event';
        $event->subtitle = <<<'EOT'
We're going to start off with a special intro I'm calling 'The Keynote That Was' (TKTW) and we will then watch two 
to three WWDC sessions. Depending on what's available at the time, we might have a few options but the best ones will be
the State of the Union sessions that are usually presented on the Tuesday morning in San Francisco.
EOT;
        $event->starts_at = $wwdcEventJune2016;
        $event->ends_at = $wwdcEventJune2016->copy()->addHours(3);
        $event->location = 'Teamsquare';
        $event->location_link = 'https://teamsquare.co/contact';
        $event->address_display = 'Level 1, 520 Bourke Street, Melbourne';
        $event->address = 'Level 1, 520 Bourke Street, Melbourne VIC 3000';
        $event->lat = -37.8153744;
        $event->lng = 144.958427;
        $event->tickets = 'http://melbournecocoaheads-wwdc-2016.eventbrite.com.au';
        $event->contact = 'https://twitter.com/melbournecocoa';
        $event->contact_name = 'Jesse Collis';
        $event->save();
        $event->sponsors()->detach();
        $event->sponsors()->attach(Sponsor::where('name', '=', 'Teamsquare')->first());
        $event->sponsors()->attach(Sponsor::where('name', 'Odecee')->first());
    }
 public function sponsors()
 {
     $logos = Sponsor::where('active', 1)->where('top_sponsor', 0)->get()->sortBy('ranking');
     $top_sponsors = Sponsor::where('active', 1)->where('top_sponsor', 1)->get()->sortBy('ranking');
     return view('pages.sponsors', compact('logos', 'top_sponsors'));
 }