skip to Main Content
@extends('layouts.user')

@push('css')
    
@endpush

@section('contents')


<div class="dashboard--content-item">
          <h4 style="margin-top: 3%; margin-bottom: 4%; padding-left: 5px;">Your Investments..</h4>

    <div class="table-responsive table--mobile-lg">
        <table class="table bg--body">
            <thead>
                <tr>
                    <th>@lang('Transaction')</th>
                    <th>@lang('Method')</th>
                    <th>@lang('Plan')</th>
                    <th>@lang('Method')</th>
                    <th>@lang('Profit')</th>
                    <th>@lang('Status')</th>
                    <th>@lang('Remaining time')</th>
                </tr>
            </thead>
            <tbody>
                
                

         






       
                
              @if (count($invests) == 0)
             
              <tr>
                <td colspan="12">
                  <h4 class="text-center m-0 py-2">{{__('No Data Found')}}</h4>
                </td>
              </tr>
              @else



                @foreach ($invests as $key=>$data)
                 
                  <tr>
                      <td data-label="Transaction ID">
                        <div>
                          {{ strtoupper($data->transaction_no) }}
                        </div>
                      </td>

                      <td data-label="Payment">
                        <div>
                          {{ strtoupper($data->method) }}
                        </div>
                      </td>

                      <td data-label="Plan - Amount">
                        <div>
                          {{ $data->plan->title }} - {{ showPrice($data->amount) }}
                        </div>
                      </td>

                      <td data-label="Profit Amount">
                        <div style="color: #08a312 !important; font-weight: 600;">
                          {{ showPrice($data->profit) }}
                        </div>
                      </td>

                      @if ($data->status == 0)
                        <td data-label="Status">
                          <div>
                              <span class="badge btn--warning btn-sm status">@lang('Pending')</span>
                          </div>
                        </td>
                      @elseif($data->status == 1)
                        <td data-label="Status">
                          <div>
                              <span class="badge btn--info btn-sm status">@lang('In Progress')</span>
                          </div>
                        </td>
                      @elseif($data->status == 2)
                        <td data-label="Status">
                          <div>
                              <span class="badge btn--success btn-sm status">@lang('Completed')</span>
                          </div>
                        </td>
                      @endif

                      @if ($data->status == 0)
                        <td data-label="Remaining Time">
                          <div>
                              @lang('Nothing')
                          </div>
                        </td>
                      @elseif($data->status == 1) 
                        <td data-label="Remaining Time" class="countdown" data-date="{{ CarbonCarbon::parse($data->profit_time) }}"></td>
                      
                      @elseif($data->status == 2)
                        <td data-label="Remaining Time">
                          <div>
                            <span class="badge btn--success btn-sm">@lang('Finished')</span>
                          </div>
                        </td>
                      @endif

                  </tr>
                @endforeach
              @endif












              
             
            </tbody>
        </table>
    </div>
</div>
@endsection

@push('js')
<script type="text/javascript">
    'use strict';

    $('.countdown').each(function(){
        var date = $(this).data('date');
        var countDownDate = new Date(date).getTime();
        var $this = $(this);
        var x = setInterval(function() {
          var now = new Date().getTime();
          var distance = countDownDate - now;

          var days = Math.floor(distance / (1000 * 60 * 60 * 24));
          var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
          var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
          var seconds = Math.floor((distance % (1000 * 60)) / 1000);

          var text = days + "d " + hours + "h "
          + minutes + "m " + seconds + "s ";
          $this.html(text);

          if (distance < 0) {
            clearInterval(x);
           var text = "Calculating.."; $this.html(text);
         
           
        
          }
        }, 1000);
    });

</script>
@endpush

This is the Code. How Can I show the table data based on the current user logged in. Everything is working fine but it doesn’t call the database data based on the user_id. What Can I do now. I have very low knowledge in laravel and php.

I have no idea why its not working. I have tried some methods available already in Stack Overflow but they are not working properly or I am not sure I have placed them properly. so Please help me to fix this.

See this Video: https://www.luveedu.com/2.mp4 then I hope you will be able to understand what’s happening.

2

Answers


  1. Use, Auth->user(). So, that you can access all data of current logged in user. By using Auth::id(), you can access current user’s id.

    Login or Signup to reply.
  2. Use Auth facade provided by laravel

    Auth::user();
    

    You can access any property of the user table from db with auth. like:

    Auth::user()->created_at
    Auth::user()->email
    

    or any field from the users table.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search