Sponzy larvarel 10 script addition fix

my_trialsubscription.blade.php is giving an error Attempt to read property “id” on null after a trial link is created. after the link is created and someone try’s to use the link the error shows up. i have looked on line and i can’t find the solution to the problem i am hoping someone here can help. i believe it is written in Lavarel 10 or 11.
https://hornywildgirls.com/Admin?token=eyJpdiI6IlFXL1YycTVuU2hQR2xBRVJlYUtuaXc9PSIsInZhbHVlIjoicmpORjVZRWE4cEFHOVFLV2t1NTkrQnZJWWM0bDdGTzNOMjJ2VVZISGNMWT0iLCJtYWMiOiJmMWI2N2IwYzFmYmEwZWQ2NjllOGI3ODA5ZDdmYmEzODJiOWY0OTAyNmE5ZDY5Zjg0ZGZjYzcyYTA1ZWM4YzZkIiwidGFnIjoiIn0=

@extends('layouts.app')

@section('title') {{__('users.my_subscriptions')}} -@endsection

@section('content')

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>

<style>
    .cancel-button {
        background-color: #555;
        color: #fff;
        height: 50px;
        transition: background-color 0.3s ease, color 0.3s ease;
    }

    .create-link-button {
        background-color: #008CBA;
        color: #fff;
        height: 50px;
        transition: background-color 0.3s ease, color 0.3s ease;
    }

    button:hover {
        opacity: 0.8;
    }
</style>

<section class="section section-sm">
    <div class="container">
        <div class="row justify-content-center text-center mb-sm">
            <div class="col-lg-8 py-5">
                <h2 class="mb-0 font-montserrat"><i class="feather icon-user-check mr-2"></i> {{__('Trial Subscription')}}</h2>
                <p class="lead text-muted mt-0">{{__('')}}</p>
            </div>
        </div>
        <div class="row">

            @include('includes.cards-settings')


            @if ($trial_link_exist && !empty($link))


            <div class="col-md-6 col-lg-9 mb-5 mb-lg-0">


                <div class="alert alert-primary alert-dismissible fade show" role="alert" style="height : 4%">
                    <i class="fa fa-info-circle mr-2"></i>
                    <span> You already have an active trial link.
                    </span>
                </div>

                <div class="form-group">
                 Trial Link : <input type="text" id="generated-link" class="form-control" readonly value="{{$link}}">
                </div>
                <span>Share this link with your subscribers</span>

            </div>



            @else

            <div class="col-md-6 col-lg-9 mb-5 mb-lg-0">

                <div class="container">
                    <form>
                        <div class="form-group">
                            <input type="text" id="trial-link-name" class="form-control" maxlength="64" placeholder="Trial Link Name">
                        </div>
                        <div class="form-group">
                            <label for="offer-limit" class="form-label">Offer limit</label>
                            <select id="offer-limit" class="form-control">
                            <option value="no limit">No Limit</option>
                            <option value="1">1 subscribers</option>
                            <option value="2">2 subscribers</option>
                            <option value="3">3 subscribers</option>
                            <option value="4">4 subscribers</option>
                            <option value="5">5 subscribers</option>
                            <option value="6">6 subscribers</option>
                            <option value="7">7 subscribers</option>
                            <option value="8">8 subscribers</option>
                            <option value="9">9 subscribers</option>
                            <option value="10">10 subscribers</option>
                            <option value="20">20 subscribers</option>
                            <option value="30">30 subscribers</option>
                            <option value="40">40 subscribers</option>
                            <option value="50">50 subscribers</option>
                            <option value="60">60 subscribers</option>
                            <option value="70">70 subscribers</option>
                            <option value="80">80 subscribers</option>
                            <option value="90">90 subscribers</option>
                            <option value="100">100 subscribers</option>
                                <!-- Add more options as needed -->
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="offer-expiration" class="form-label">Offer expiration</label>
                            <select id="offer-expiration" class="form-control">
                            <option value="never expires">Never Expires</option>
                            <option value="1">1 days</option>
                            <option value="2">2 days</option>
                            <option value="3">3 days</option>
                            <option value="4">4 days</option>
                            <option value="5">5 days</option>
                            <option value="6">6 days</option>
                            <option value="7">7 days</option>
                            <option value="9">9 days</option>
                            <option value="10">10 days</option>
                            <option value="11">11 days</option>
                            <option value="12">12 days</option>
                            <option value="13">13 days</option>
                            <option value="14">14 days</option>
                            <option value="15">15 days</option>
                            <option value="16">16 days</option>
                            <option value="17">17 days</option>
                            <option value="18">18 days</option>
                            <option value="19">19 days</option>
                            <option value="20">20 days</option>
                            <option value="21">21 days</option>
                            <option value="22">22 days</option>
                            <option value="23">23 days</option>
                            <option value="24">24 days</option>
                            <option value="25">25 days</option>
                            <option value="26">26 days</option>
                            <option value="27">27 days</option>
                            <option value="28">28 days</option>
                            <option value="29">29 days</option>
                            <option value="30">30 days</option>
                            <option value="40">40 days</option>
                            <option value="50">50 days</option>
                            <option value="60">60 days</option>
                                <!-- Add more options as needed -->
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="free-trial-duration" class="form-label">Free trial duration</label>
                            <select id="free-trial-duration" class="form-control">
                            <option value="never expires">Never Expires</option>
                            <option value="1">1 days</option>
                            <option value="2">2 days</option>
                            <option value="3">3 days</option>
                            <option value="4">4 days</option>
                            <option value="5">5 days</option>
                            <option value="6">6 days</option>
                            <option value="7">7 days</option>
                            <option value="9">9 days</option>
                            <option value="10">10 days</option>
                            <option value="11">11 days</option>
                            <option value="12">12 days</option>
                            <option value="13">13 days</option>
                            <option value="14">14 days</option>
                            <option value="15">15 days</option>
                            <option value="16">16 days</option>
                            <option value="17">17 days</option>
                            <option value="18">18 days</option>
                            <option value="19">19 days</option>
                            <option value="20">20 days</option>
                            <option value="21">21 days</option>
                            <option value="22">22 days</option>
                            <option value="23">23 days</option>
                            <option value="24">24 days</option>
                            <option value="25">25 days</option>
                            <option value="26">26 days</option>
                            <option value="27">27 days</option>
                            <option value="28">28 days</option>
                            <option value="29">29 days</option>
                            <option value="30">30 days</option>
                            <option value="3 months">3 months</option>
                            <option value="5 months">6 months</option>
                            <option value="12 months">12 months</option>

                                <!-- Add more options as needed -->
                            </select>
                        </div>
                        <div class="form-buttons">
                            <button type="button" class="cancel-button">Cancel</button>
                            <button type="submit" class="create-link-button">Create Link</button>
                        </div>
                    </form>
                </div>

            </div><!-- end col-md-6 -->


            @endif





        </div>
    </div>

</section>

<script>
    $(document).ready(function() {

        $(".create-link-button").click(function(event) {

            event.preventDefault();

            if ($("#trial-link-name").val() == "") {
                alert("Enter the Trial Link Name");
            } else {

                var formData = {

                    'trial_link_name': $("#trial-link-name").val(),
                    'offer_limit': $("#offer-limit").val(),
                    'offer_expiration': $("#offer-expiration").val(),
                    'free_trial_duration': $("#free-trial-duration").val(),
                    '_token': '{{ csrf_token() }}'


                }

                $.ajax({

                    type: 'POST',
                    url: 'triallink',
                    data: formData,
                    dataType: 'json',
                    success: function(data) {

                        if (data.code == 500) {
                            alert("Trial Link is already generated for this ID");
                        } else if (data.code == 501) {


                            location.reload();


                        }

                    },
                    error: function(xhr) {

                        alert("error " + xhr.responseJSON.errors);


                    }


                });


            }



        });

    });
</script>
@endsection

    

Route::view(‘/help’,’pages.test’); Route::get(‘my/trialsubscribers’, [UserController::class, ‘mytrialSubscriptions’]); Route::get(‘my/promotion’, [UserController::class, ‘mypromotion’]); Route::post(‘my/triallink’, [UserController::class, ‘trialLink’]); Route::post(‘my/promotion’, [UserController::class, ‘mypromotion’]); Route::get(‘/access/{dynamicName}’, ‘AppHttpControllersLinkController@access’)->name(‘link.access’);

// *******************************************Custom code

    $token_time = "";

    if (isset($_REQUEST['token'])) {

      // date_default_timezone_set("Asia/Calcutta");

      $creator_id = auth()->user()->id;

      $token_time = decrypt($_REQUEST['token']);

      $expired_time_link = DB::table("trial_links")->where('creator_id', $creator_id)->get();

      $expired_time_link =  $expired_time_link[0]->expired_at;


      if (strtotime(now()) >= strtotime($expired_time_link)) {

        $username = auth()->user()->username;

        return redirect()->to('/' . $username);
      } else {

        return view('users.profile', [
          'user' => $user,
          'updates' => $updates,
          'hasPages' => $updates->hasPages(),
          'totalPosts' => $user->updates()->select('updates.id', 'updates.user_id')->count(),
          'totalPhotos' => $user->media()->where('media.type', 'image')->count(),
          'totalVideos' => $user->media()->where('media.type', 'video')->count(),
          'totalMusic' => $user->media()->where('media.type', 'music')->count(),
          'totalFiles' => $user->media()->where('media.type', 'file')->count(),
          'totalEpub' => $user->media()->where('media.type', 'epub')->count(),
          '_stripe' => $_stripe,
          'checkSubscription' => $checkSubscription ?? null,
          'media' => $media,
          'mediaTitle' => $mediaTitle,
          'sortPostByTypeMedia' => $sortPostByTypeMedia,
          'allPayment' => $allPayment,
          'paymentIncomplete' => $paymentIncomplete ?? null,
          'likeCount' => $likeCount,
          'categories' => $categories,
          'paymentGatewaySubscription' => $paymentGatewaySubscription->payment_gateway ?? null,
          'subscriptionsActive' => $subscriptionsActive,
          'plans' => $plans,
          'userPlanMonthlyActive' => $userPlanMonthlyActive ?? null,
          'userProducts' => $userProducts,
          'shopCategories' => $shopCategories ?? null,
          'token_time' => $token_time
        ]);
      }
    } else {

      return view('users.profile', [
        'user' => $user,
        'updates' => $updates,
        'hasPages' => $updates->hasPages(),
        'totalPosts' => $user->updates()->select('updates.id', 'updates.user_id')->count(),
        'totalPhotos' => $user->media()->where('media.type', 'image')->count(),
        'totalVideos' => $user->media()->where('media.type', 'video')->count(),
        'totalMusic' => $user->media()->where('media.type', 'music')->count(),
        'totalFiles' => $user->media()->where('media.type', 'file')->count(),
        'totalEpub' => $user->media()->where('media.type', 'epub')->count(),
        '_stripe' => $_stripe,
        'checkSubscription' => $checkSubscription ?? null,
        'media' => $media,
        'mediaTitle' => $mediaTitle,
        'sortPostByTypeMedia' => $sortPostByTypeMedia,
        'allPayment' => $allPayment,
        'paymentIncomplete' => $paymentIncomplete ?? null,
        'likeCount' => $likeCount,
        'categories' => $categories,
        'paymentGatewaySubscription' => $paymentGatewaySubscription->payment_gateway ?? null,
        'subscriptionsActive' => $subscriptionsActive,
        'plans' => $plans,
        'userPlanMonthlyActive' => $userPlanMonthlyActive ?? null,
        'userProducts' => $userProducts,
        'shopCategories' => $shopCategories ?? null,
        'token_time' => $token_time
      ]);
    }



    //***************************************Custom code ends

i have looked on google for a solution and tried the solutions there but not luck. i am hoping to find someone who can help with the error. .

New contributor

lenard blanks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật