public function getInvolved() { $page = $this->contentRepository->getPageByName('get involved'); $sponsors = Sponsor::ordered()->get(); $charities = Charity::ordered()->get(); $expeditionistPdf = FileResource::where('name', 'Become an expeditionist')->first(); $volunteerPdf = FileResource::where('name', 'Become a volunteer')->first(); return view('front.pages.getinvolved')->with(compact('page', 'sponsors', 'charities', 'expeditionistPdf', 'volunteerPdf')); }
/** *@test */ public function sponsors_can_be_ordered_by_passing_an_ordered_list_of_ids() { factory(Sponsor::class)->create(['name' => 'second', 'id' => 1]); factory(Sponsor::class)->create(['name' => 'first', 'id' => 2]); factory(Sponsor::class)->create(['name' => 'fourth', 'id' => 3]); factory(Sponsor::class)->create(['name' => 'third', 'id' => 4]); Sponsor::setOrder([2, 1, 4, 3]); $ordered = Sponsor::ordered()->get(); $this->assertEquals('first', $ordered->first()->name); $this->assertEquals('second', $ordered[1]->name); $this->assertEquals('third', $ordered[2]->name); $this->assertEquals('fourth', $ordered->last()->name); }
/** *@test */ public function sponsors_can_have_their_order_set_by_posting_to_endpoint() { factory(Sponsor::class)->create(['name' => 'second', 'id' => 1]); factory(Sponsor::class)->create(['name' => 'first', 'id' => 2]); factory(Sponsor::class)->create(['name' => 'fourth', 'id' => 3]); factory(Sponsor::class)->create(['name' => 'third', 'id' => 4]); $this->asAnAdminUser(); $this->withoutMiddleware(); $response = $this->call('POST', '/admin/sponsors/order', ['order' => [2, 1, 4, 3]]); $this->assertEquals(200, $response->status()); $ordered = Sponsor::ordered()->get(); $this->assertEquals('first', $ordered->first()->name); $this->assertEquals('second', $ordered[1]->name); $this->assertEquals('third', $ordered[2]->name); $this->assertEquals('fourth', $ordered->last()->name); }
public function show() { $sponsors = Sponsor::ordered()->get(); return view('admin.sponsors.order')->with(compact('sponsors')); }
protected function getSponsors() { return Cache::remember('home:sponsors', static::CACHE_DURATION, function () { return Sponsor::ordered()->get(); }); }