/**
  * 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());
     }
 }
Пример #2
0
 /**
  * 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);
 }