# Fundme Crowdfunding Platform v2.4

Updated: 09, November 2018

## Changelog

- Fixed
- Update rewards
- Removed
- Iframe height
- Validate email in donation page
- Removing campaigns
- Campaign embed
- Column comment nullable
- Method not available `trowValidationException`
- Added
- Upgrade to Laravel 5.7
- `MustVerifyEmail` and `ResetPassword` in User model
- ResetPassword template
- Delete donations pending (Bank Transfer)
- Name, email of organizer and url campaign in email sent to user after donating
- Changed
- Validation images dimensions
- Description validation

## Affected files

- `app / Models`
- User.php

    <?php
      namespace App\Models;

    use Laravel\Cashier\Billable;
    use Illuminate\Notifications\Notifiable;
    use Illuminate\Contracts\Auth\MustVerifyEmail;
    use Illuminate\Foundation\Auth\User as Authenticatable;
    use App\Notifications\ResetPassword as ResetPasswordNotification;

    class User extends Authenticatable
    {
        use Notifiable, Billable;

        /**
         * The attributes that are mass assignable.
         *
         * @var array
         */
        protected $fillable = [
            'name', 'password', 'email', 'avatar', 'status','role','token','confirmation_code','countries_id',
        ];

        /**
         * The attributes that should be hidden for arrays.
         *
         * @var array
         */
        protected $hidden = [
            'password', 'remember_token',
        ];

        public function sendPasswordResetNotification($token) {

            $this->notify(new ResetPasswordNotification($token));
        }

    	public function campaigns() {
            return $this->hasMany('App\Models\Campaigns');
        }

    	public function country() {
            return $this->belongsTo('App\Models\Countries', 'countries_id')->first();
        }

    }

- `app / Http / Controllers`
- AdminController.php

    //Delete campaign Reported
    $campaignReporteds = CampaignsReported::where('campaigns_id',$request->id)->get();

    if($campaignReporteds) {
    	foreach ($campaignReporteds as $campaignReported) {
    			$campaignReported->delete();
    	}//<-- foreach
    }// IF

    $rules = array('name' => 'required',
              'slug'        => 'required|ascii_only|unique:categories',
              'thumbnail'   => 'mimes:jpg,gif,png,jpe,jpeg|dimensions:min_width=457,min_height=359',
              );

    $rules = array('name' => 'required',
        'slug'        => 'required|ascii_only|unique:categories',
        'thumbnail'   => 'mimes:jpg,gif,png,jpe,jpeg|dimensions:min_width=457,min_height=359',
        );

Add this code to the end of the `AdminController.php` file

    public function deleteDonation(Request $request){

      	  $sql = Donations::findOrFail($request->id);

            $sql->delete();

            return redirect('panel/admin/donations');

      	}//<--- End Method

- CampaignsController.php

    'photo' => 'required|mimes:jpg,gif,png,jpe,jpeg|dimensions:min_width='.$dimensions[0].',min_height='.$dimensions[1].'|max:'.$this->settings->file_size_allowed.'',

    'photo' => 'mimes:jpg,gif,png,jpe,jpeg|dimensions:min_width='.$dimensions[0].',min_height='.$dimensions[1].'|max:'.$this->settings->file_size_allowed.'',

    //Delete campaign Reported
    $campaignReporteds = CampaignsReported::where('campaigns_id',$this->request->id)->get();

    if($campaignReporteds) {
    foreach ($campaignReporteds as $campaignReported) {
      $campaignReported->delete();
    }//<-- foreach
    }// IF

    'photo' => 'mimes:jpg,gif,png,jpe,jpeg|dimensions:min_width='.$dimensions[0].',min_height='.$dimensions[1].'|max:'.$this->settings->file_size_allowed.'',

    'photo' => 'nullable|mimes:jpg,gif,png,jpe,jpeg|dimensions:min_width='.$dimensions[0].',min_height='.$dimensions[1].'|max:'.$this->settings->file_size_allowed.'',

- DonationsController.php

    'email' => 'required|email|max:100',

    'comment' => 'nullable|max:100',

    if ($validator->fails()) {
      return response()->json([
          'success' => false,
          'errors' => $validator->getMessageBag()->toArray(),
      ]);
    }

    if($this->request->comment == ''){
      $this->request->comment = '';
    }

    protected function sendEmail($campaign)
    {
      $sender       = $this->settings->email_no_reply;
      $titleSite    = $this->settings->title;
      $_emailUser   = $this->request->email;
      $campaignID   = $campaign->id;
      $campaignTitle = $campaign->title;
      $organizerName = $campaign->user()->name;
      $organizerEmail = $campaign->user()->email;
      $fullNameUser = $this->request->fullname;
      $paymentGateway = $this->request->payment_gateway;

      Mail::send('emails.thanks-donor', array(
            'data' => $campaignID,
            'fullname' => $fullNameUser,
            'title_site' => $titleSite,
            'campaign_id' => $campaignID,
            'organizer_name' => $organizerName,
            'organizer_email' => $organizerEmail,
            'payment_gateway' => $paymentGateway,
          ),
      function($message) use ( $sender, $fullNameUser, $titleSite, $_emailUser, $campaignTitle)
        {
            $message->from($sender, $titleSite)
              ->to($_emailUser, $fullNameUser)
            ->subject( trans('misc.thanks_donation').' - '.$campaignTitle.' || '.$titleSite );
        });
    }

- PagesController.php
Replace this file completely `PagesController.php`
- RewardsController.php

    if( $sql->donations() ) {
      $countPledge = $sql->donations()->where('rewards_id',$sql->id)->count();
    } else {
      $countPledge = null;
    }

- UserController.php

    public function update_account(Request $request)
    {

     $input = $request->all();
     $id = Auth::user()->id;

     $validator = $this->validator($input,$id);

     if ($validator->fails()) {
            return redirect()->back()
                        ->withErrors($validator)
                        ->withInput();
        }

    public function update_password(Request $request)
    {

     $input = $request->all();
     $id = Auth::user()->id;

       $validator = Validator::make($input, [
    	'old_password' => 'required|min:6',
          'password'     => 'required|min:6',
    	]);

    	if ($validator->fails()) {
             return redirect()->back()
                         ->withErrors($validator)
                         ->withInput();
         }

    'photo' => 'required|mimes:jpg,gif,png,jpe,jpeg|dimensions:min_width=125,min_height=125|max:'.$settings->file_size_allowed.'',

- `public / css`
- main.css

    .description iframe {
     max-height: 500px !important;
    }

- `resources / views`

- `admin`
- edit-campaign.blade.php
- donation-view.blade.php

- `emails`
- password_reset.blade.php NEW
- thanks-donor.blade.php

- `includes`
- embed.blade.php

- `routes`
- web.php

    Route::post('delete/donation','AdminController@deleteDonation');

Any problem or doubt send me an email to miguelvasquez991@gmail.com and do not forget to visit miguelvasquez.net