/** * Save charity settings * * @return Response */ public function postsettings() { $input = Input::all(); $profile = User::find(Auth::user()->id); if (!$profile->charity) { $charity = new Charity(); } else { $charity = Charity::find($profile->charity_id); } $charity->name = $input['name']; $charity->goal = $input['goal']; $charity->description = $input['description']; $charity->save(); $profile->charity_id = $charity->id; $profile->profile_url = Str::slug($input['name']); $profile->phone = $input['phone']; $profile->country = $input['country']; $profile->city = $input['city']; $profile->picture = $input['picture_id']; $profile->zip = $input['zip']; $profile->paypal = $input['paypal']; //Disabling validation rules $profile::$rules['email'] = ''; $profile::$rules['agree'] = ''; $profile->autoHashPasswordAttributes = false; if ($profile->save(['charity_id' => 'required|exists:charity,id', 'profile_url' => 'unique:users,profile_url,' . $profile->id])) { return Redirect::to('/charity/' . $profile->profile_url); } else { return Redirect::to('charity/settings')->with('errors', $profile->errors()->all()); } }
/** * Creates new challenge for given charity and redirects user to payment * * @todo read & validate form values */ function new_challenge($charity_id) { $charity = Charity::find_by_id($charity_id); if (!$charity) { throw new PageNotFoundException(); } // FIXME: check for duplicates $challenge = new Challenge(); $challenge->charity_id = $charity->id; $challenge->user_id = $this->logged_in_user()->id; $challenge->base_donation_pence = 1000; $challenge->matching_percentage = 10; $challenge->matching_upper_limit_pence = 5000; $challenge->save(); return $this->do_prepay_challenge($challenge); }
/** * Created by PhpStorm. * User: Garrett * Date: 3/7/2015 * Time: 06:10 */ require_once "classes/Donorbid.php"; $id = $_GET['id']; $amt = $_GET['amt']; $product = $db->getProduct($id); if (is_null($product)) { $product = new Item(); } $charity = $db->getCharity($product->getCharity()); if (is_null($charity)) { $charity = new Charity(); } $seller = $product->getSeller(); if (is_null($seller)) { $seller = new User(); } $user = $_SESSION['user']; if (!$util->isValidUser($user)) { //Disabled until login is working! header('Location: login.php'); } else { } //temporary here $seller->setImage("images/creep.jpg"); ?>
//$top_charity2 = $db -> $seller -> getCharities()[1]; //$top_charity3 = $db -> $seller -> getCharities()[2]; //temp $top_charity1 = new Charity(); $top_charity2 = new Charity(); $top_charity3 = new Charity(); if (is_null($top_charity1)) { $top_charity1 = new Charity(); $top_charity1->name = ""; } if (is_null($top_charity2)) { $top_charity2 = new Charity(); $top_charity2->name = ""; } if (is_null($top_charity3)) { $top_charity3 = new Charity(); $top_charity3->name = ""; } ?> <!DOCTYPE HTML> <HTML> <HEAD> <title>DonorBid.com</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> <!-- Optional theme -->
/** * List of charities. * * @todo search and browsing by category */ function listing() { return array('charities' => Charity::find('all'), 'hide_sidebar' => true); }
/** * Handle song initialisation submit form */ public function addsong() { $input = Input::all(); $song_id = $input['song']; $song = Song::find($song_id); if ($song->artist != Auth::user()->id) { return Redirect::to('/'); } else { if (Input::has('art_cropped')) { $image = Input::get('art_cropped'); $exp = explode(",", $image); $data = base64_decode($exp[1]); $name = str_random(15); $tempfile = storage_path() . "/temp/" . $name . ""; file_put_contents($tempfile, $data); $image_info = getImageSize($tempfile); switch ($image_info['mime']) { case 'image/gif': $extension = '.gif'; break; case 'image/jpeg': $extension = '.jpg'; break; case 'image/png': $extension = '.png'; break; default: // handle errors break; } // open file a image resource $img = Image::make($tempfile); $img->save($tempfile); $large = Image::make($tempfile)->resize(120, 120)->save($song->path . "/" . $song->sample . "-large" . $extension); $small = Image::make($tempfile)->resize(50, 50)->save($song->path . "/" . $song->sample . "-small" . $extension); $song->art = $song->path . "/" . $song->sample . "-large" . $extension; unlink($tempfile); } $song->genre = $input['genre']; $song->title = $input['title']; $song->price = $input['price']; $song->description = $input['description']; $song->completed = true; if (Input::has('charity')) { if (Input::get('charity_share') > 0) { if (is_numeric(Input::get('charity_share'))) { $charity = Charity::find($input['charity']); if ($charity) { $song->charity_share = $input['charity_share']; $song->charity = $input['charity']; } } } } $song->save(); Session::forget('song'); } return Redirect::to('/artist/' . Auth::user()->profile_url); }