Support the ongoing development of Laravel.io →
Laravel Blade

I have a profile blade and we added some code to the original code for a creator to offer specials. without the code the avatar and cover images work correctly you can change them easily, with the new code you cannot change the avatar or the cover images and the creators will want to change this from time to time. I am not sure where the problem is in the code of the profile blade or the controller.

any help will be appreciated.

` <div class="card-body px-lg-5 py-lg-5 position-relative"> <div class="text-muted text-center mb-3 position-relative modal-offset"> <img src="{{Helper::getFile(config('path.avatar').$user->avatar)}}" width="100" alt="{{$user->hide_name == 'yes' ? $user->username : $user->name}}" class="avatar-modal rounded-circle mb-1"> <h6 class="font-weight-light"> {!! ('general.subscribe_month', ['price' => '<span class="font-weight-bold">'.Helper::formatPrice($price_for_first_month_discount), true.'</span>']) !!} {{('general.unlocked_content')}} {{$user->hide_name == 'yes' ? $user->username : $user->name}} <small class="w-100 d-block font-12">* {{ __('general.in_currency', ['currency_code' => $settings->currency_code]) }}</small> </h6> </div>

    @if ($totalPosts == 0)
    <div class="alert alert-warning fade show small" role="alert">
      <i class="fa fa-exclamation-triangle mr-1"></i> {{ $user->first_name }} {{ __('general.not_posted_any_content') }}
    </div>
    @endif

    <div class="text-center text-muted mb-2">
      <h5>{{__('general.what_will_you_get')}}</h5>
    </div>

    <ul class="list-unstyled">
      <li><i class="fa fa-check mr-2 @if (auth()->user()->dark_mode == 'on') text-white @else text-primary @endif"></i> {{__('general.full_access_content')}}</li>
      <li><i class="fa fa-check mr-2 @if (auth()->user()->dark_mode == 'on') text-white @else text-primary @endif"></i> {{__('general.direct_message_with_this_user')}}</li>
      <li><i class="fa fa-check mr-2 @if (auth()->user()->dark_mode == 'on') text-white @else text-primary @endif"></i> {{__('general.cancel_subscription_any_time')}}</li>
    </ul>

    <div class="text-center text-muted mb-2 @if ($allPayment->count() == 1) d-none @endif">
      <small><i class="far fa-credit-card mr-1"></i> {{__('general.choose_payment_gateway')}}</small>
    </div>

    <form method="post" action="{{url('subscription/campaign')}}" id="formSubscription">
      @csrf
      <input type="hidden" name="no_of_subscribers" value="{{$campaign_data->no_of_subscribers}}" readonly>
      <input type="hidden" name="discount" value="{{$campaign_data->discount}}" readonly>
      <input type="hidden" name="expired_at" value="{{$campaign_data->expired_at}}" readonly>
      <input type="hidden" name="stopped" value="{{$campaign_data->stopped}}" readonly>
      <input type="hidden" name="creator_id" value="{{$campaign_data->creator_id}}" readonly>
      <input type="hidden" name="campaign_id" value="{{$campaign_data->id}}" readonly />
      <input type="hidden" name="standardPrice" value="{{$user_plan[0]->price}}" readonly />
      <input type="hidden" name="discountedPrice" value="{{$price_for_first_month_discount}}" readonly />
      <input type="hidden" name="id" value="{{$user->id}}" />
      <input name="interval" value="monthly" id="subscription_plan_monthly" class="d-none" type="radio">

      @foreach ($plans as $plan)
      <input name="interval" value="{{ $plan->interval }}" id="plan-{{ $plan->interval }}" class="d-none" type="radio">
      @endforeach

      @foreach ($allPayment as $payment)
      @php


      if ($payment->recurrent == 'no') {
      $recurrent = '<br><small>'.__('general.non_recurring').'</small>';
      } else if ($payment->id == 1) {
      $recurrent = '<br><small>'.__('general.redirected_to_paypal_website').'</small>';
      } else {
      $recurrent = '<br><small>'.__('general.automatically_renewed').' ('.$payment->name.')</small>';
      }
      if ($payment->type == 'card' ) {
      $paymentName = '<i class="far fa-credit-card mr-1"></i> '.__('general.debit_credit_card').$recurrent;
      } else if ($payment->id == 1) {
      $paymentName = '<img src="'.url('img/payments', auth()->user()->dark_mode == 'off' ? $payment->logo : 'paypal-white.png').'" width="70" /> <small class="w-100 d-block">'.__('general.redirected_to_paypal_website').'</small>';
      } else {
      $paymentName = '<img src="'.url('img/payments', $payment->logo).'" width="70" />'.$recurrent;
      }
      @endphp

      <div class="custom-control custom-radio mb-3">
        <input name="payment_gateway" required value="{{$payment->name}}" id="radio{{$payment->name}}" @if ($allPayment->count() == 1 && Helper::userWallet('balance') == 0) checked @endif class="custom-control-input" type="radio">
        <label class="custom-control-label" for="radio{{$payment->name}}">
          <span><strong>{!!$paymentName!!}</strong></span>
        </label>
      </div>

      @if ($payment->name == 'Stripe' && ! auth()->user()->pm_type != '')
      <div id="stripeContainer" class="@if ($allPayment->count() == 1 && $payment->name == 'Stripe')d-block @else display-none @endif">
        <a href="{{ url('settings/payments/card') }}" class="btn btn-secondary btn-sm mb-3 w-100">
          <i class="far fa-credit-card mr-2"></i>
          {{ __('general.add_payment_card') }}
        </a>
      </div>
      @endif

      @if ($payment->name == 'Paystack' && ! auth()->user()->paystack_authorization_code)
      <div id="paystackContainer" class="@if ($allPayment->count() == 1 && $payment->name == 'Paystack')d-block @else display-none @endif">
        <a href="{{ url('my/cards') }}" class="btn btn-secondary btn-sm mb-3 w-100">
          <i class="far fa-credit-card mr-2"></i>
          {{ __('general.add_payment_card') }}
        </a>
      </div>
      @endif

      @endforeach
      @if ($settings->disable_wallet == 'on' && Helper::userWallet('balance') != 0 || $settings->disable_wallet == 'off')
      <div class="custom-control custom-radio mb-3">
        <input name="payment_gateway" required @if (Helper::userWallet('balance')==0) disabled @endif value="wallet" id="radio0" class="custom-control-input" type="radio">
        <label class="custom-control-label" for="radio0">
          <span>
            <strong>
              <i class="fas fa-wallet mr-1 icon-sm-radio"></i> {{ __('general.wallet') }}
              <span class="w-100 d-block font-weight-light">
                {{ __('general.available_balance') }}: <span class="font-weight-bold mr-1">{{Helper::userWallet()}}</span>
                @if (Helper::userWallet('balance') != 0 && $settings->wallet_format != 'real_money')
                <i class="bi-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="{{Helper::equivalentMoney($settings->wallet_format)}}"></i>
                @endif
                @if (Helper::userWallet('balance') == 0)
                <a href="{{ url('my/wallet') }}" class="link-border">{{ __('general.recharge') }}</a>
                @endif
              </span>

              <span class="w-100 d-block small">{{ __('general.automatically_renewed_wallet') }}</span>
            </strong>
          </span>
        </label>
      </div>
      @endif

      <div class="alert alert-danger display-none" id="error">
        <ul class="list-unstyled m-0" id="showErrors"></ul>
      </div>


      <div class="custom-control custom-control-alternative custom-checkbox">
        <input class="custom-control-input" required id=" customCheckLogin" name="agree_terms" type="checkbox">
        <label class="custom-control-label" for=" customCheckLogin">
          <span>{{__('general.i_agree_with')}} <a href="{{$settings->link_terms}}" target="_blank">{{__('admin.terms_conditions')}}</a></span>
        </label>
      </div>

      @if ($taxRatesCount != 0 && auth()->user()->isTaxable()->count())
      <ul class="list-group list-group-flush border-dashed-radius mt-3">
        @foreach (auth()->user()->isTaxable() as $tax)
        <li class="list-group-item py-1 list-taxes">
          <div class="row">
            <div class="col">
              <small>{{ $tax->name }} {{ $tax->percentage }}% {{ __('general.applied_price') }}</small>
            </div>
          </div>
        </li>
        @endforeach
      </ul>
      @endif


      <div class="text-center">
        <button type="submit" class="btn btn-primary mt-4 w-100 subscriptionBtn" onclick="$('#subscription_plan_monthly').trigger('click');">
          <i></i> {{__('general.subscribe_month', ['price' => Helper::formatPrice($price_for_first_month_discount)], true)}}
        </button>

        <div class="w-100 mt-2">
          <button type="button" class="btn e-none p-0" data-dismiss="modal">{{__('admin.cancel')}}</button>
        </div>
      </div>

      @include('includes.site-billing-info')
    </form>
  </div>
</div>
</div> </div> `

` public function uploadAvatar() { $validator = Validator::make($this->request->all(), [ 'avatar' => 'required|mimes:jpg,gif,png,jpe,jpeg|dimensions:min_width=200,min_height=200|max:' . $this->settings->file_size_allowed . '', ]);

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

// PATHS
$path = config('path.avatar');

//<--- HASFILE PHOTO
if ($this->request->hasFile('avatar')) {
  $photo     = $this->request->file('avatar');
  $extension = $this->request->file('avatar')->getClientOriginalExtension();
  $avatar    = strtolower(auth()->user()->username . '-' . auth()->id() . time() . str_random(10) . '.' . $extension);

  $imgAvatar = Image::make($photo)->orientate()->fit(200, 200, function ($constraint) {
    $constraint->aspectRatio();
    $constraint->upsize();
  })->encode($extension);

  // Copy folder
  Storage::put($path . $avatar, $imgAvatar);

  //<<<-- Delete old image -->>>/
  if (auth()->user()->avatar != $this->settings->avatar) {
    Storage::delete(config('path.avatar') . auth()->user()->avatar);
  }

  // Update Database
  auth()->user()->update(['avatar' => $avatar]);

  return response()->json([
    'success' => true,
    'avatar' => Helper::getFile($path . $avatar),
  ]);
} //<--- HASFILE PHOTO

}

public function uploadCover(Request $request) { $settings = AdminSettings::first();

$validator = Validator::make($this->request->all(), [
  'image' => 'required|mimes:jpg,gif,png,jpe,jpeg|dimensions:min_width=800,min_height=400|max:' . $settings->file_size_allowed . '',
]);

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

// PATHS
$path = config('path.cover');

//<--- HASFILE PHOTO
if ($this->request->hasFile('image')) {
  $photo       = $this->request->file('image');
  $widthHeight = getimagesize($photo);
  $extension   = $photo->getClientOriginalExtension();
  $cover       = strtolower(auth()->user()->username . '-' . auth()->id() . time() . str_random(10) . '.' . $extension);

  //=============== Image Large =================//
  $width     = $widthHeight[0];
  $height    = $widthHeight[1];
  $max_width = $width < $height ? 800 : 1900;

  if ($width > $max_width) {
    $coverScale = $max_width / $width;
  } else {
    $coverScale = 1;
  }

  $scale    = $coverScale;
  $widthCover = ceil($width * $scale);

  $imgCover = Image::make($photo)->orientate()->resize($widthCover, null, function ($constraint) {
    $constraint->aspectRatio();
    $constraint->upsize();
  })->encode($extension);

  // Copy folder
  Storage::put($path . $cover, $imgCover);

  if (auth()->user()->cover != $this->settings->cover_default) {
    //<<<-- Delete old image -->>>/
    Storage::delete(config('path.cover') . auth()->user()->cover);
  }

  // Update Database
  auth()->user()->update(['cover' => $cover]);

  return response()->json([
    'success' => true,
    'cover' => Helper::getFile($path . $cover),
  ]);
} //<--- HASFILE PHOTO

}`

``

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.