public function index($permalink = null)
 {
     $selectedOrg = null;
     if ($permalink) {
         $rawOrg = Organization::wherePermalink($permalink)->with('beneficiaries')->first();
         $selectedOrg = $this->transformer->transform($rawOrg);
     }
     $allOrgs = Organization::orderBy('name')->get();
     return View::make($this->package . '::frontend.organizations.index', ['campaign' => Campaign::current(), 'selectedOrg' => $selectedOrg, 'allOrgs' => $allOrgs]);
 }
 public function run()
 {
     DB::table('organizations')->delete();
     $o = Organization::create(['id' => 1, 'permalink' => 'abc', 'name' => 'Parent Church', 'abbreviation' => 'PC', 'address1' => '4350 North Point Parkway', 'city' => 'Alpharetta', 'state' => 'GA', 'postal_code' => '30022', 'country' => 'US', 'from_email' => '*****@*****.**']);
     $o->campaigns()->sync([1, 2, 3, 4]);
     $o = Organization::create(['id' => 2, 'permalink' => 'bcd', 'parent_organization_id' => 1, 'name' => 'Child Church', 'abbreviation' => 'CC', 'address1' => '4350 North Point Parkway', 'city' => 'Alpharetta', 'state' => 'GA', 'postal_code' => '30022', 'country' => 'US', 'from_email' => '*****@*****.**']);
     $o->campaigns()->sync([3, 4]);
     $o = Organization::create(['id' => 3, 'permalink' => 'cde', 'parent_organization_id' => 1, 'name' => 'Third Church', 'abbreviation' => 'TC', 'address1' => '4350 North Point Parkway', 'city' => 'Alpharetta', 'state' => 'GA', 'postal_code' => '30022', 'country' => 'US', 'from_email' => '*****@*****.**']);
     $o->campaigns()->sync([1, 2, 3]);
     $o = Organization::create(['id' => 4, 'permalink' => 'def', 'name' => 'Unrelated Church', 'abbreviation' => 'UC', 'address1' => '4350 North Point Parkway', 'city' => 'Alpharetta', 'state' => 'GA', 'postal_code' => '30022', 'country' => 'US', 'from_email' => '*****@*****.**']);
     $o->campaigns()->sync([1, 2, 3]);
 }
 public function compose(View $view)
 {
     parent::compose($view);
     $user_org = '';
     if (Auth::check()) {
         try {
             $user_org = Organization::where('id', '=', Auth::user()->organization_id)->first();
         } catch (\Exception $e) {
             // leave empty
         }
     }
     if ($now = Input::get('time')) {
         $now = new Carbon($now);
     } else {
         $now = Carbon::now();
     }
     $view_data = ['userOrganization' => $user_org, 'config' => \NpmWeb\ServiceOpportunities\Models\Config::singleton(), 'now' => $now];
     $view->with($view_data);
 }