shone83

shone83

Member Since 2 Years Ago

Kragujevac

Experience Points
2,330
Total
Experience

2,670 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
2,330 XP
Mar
24
1 week ago
Activity icon

Replied to Google Chart Not Working With Array, Just With Number

I got it @deansatch I complicated it. All I need to do in controller is:

        $settlements = Settlement::where('town_id', Auth::user()->town_id)
          ->where('coordinator_id', '1')
          ->with('members')
          ->get();

and in view:

                    '{{$settlement->name}}', 
                    {{$settlement->members->count()}},
                    {{$settlement->last_result}},
                    {{$settlement->expected_result}}

working great. Thanks for help

Mar
19
2 weeks ago
Activity icon

Replied to Google Chart Not Working With Array, Just With Number

I want to do that, but I don't really know how. Only thing I understand from what you saying is to do this:

@extends('layouts.app')

@section('content')

  <div class="container">

      <script type="text/javascript">
        google.charts.load('current', {'packages':['corechart']});
        google.charts.setOnLoadCallback(drawVisualization);
  
        function drawVisualization() {
          // Some raw data (not necessarily accurate)
          var data = google.visualization.arrayToDataTable([
           [
             'Месни одбори', 
             'Капиларни',
             'Последњи резултат'
           ],
  
           @if ($settlements)
  
             @foreach ($settlements as $settlement)
  
               @if (($settlement->members->count()) > '0')
  
                 [
  
                   '{{$settlement->name}}',
                    {{$settlement->members->count()}},
                    803
  
                 ],
  
               @endif
  
             @endforeach
  
           @endif
  
        ]);
  
        var options = {
          title : 'Реон1',
          seriesType: 'bars',
          series: {
            1: {type: 'line'}
          },
          colors: ['blue', 'red'],
        };
  
        var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
      </script>

      <div id="chart_div" style="width: 'auto'; height: 500px;"></div>
    

  </div>

@endsection

where I'm getting this: https://ibb.co/t3x5qfz

which is fine, that is what I want. But, I don't want just that number 803 which is forming straight line, I want numbers that I get in variable $last_results, that suppose to form line with numbers 808, 703, 186, 653.

I'm not lazy just I don't have that knowledge I guess. Sorry for bad english too :)

Activity icon

Replied to Google Chart Not Working With Array, Just With Number

What if I do get() instead of pluck() and code look like this:

        $settlements = Settlement::where('town_id', Auth::user()->town_id)
          ->where('coordinator_id', '1')
          ->with('members')
          ->get();

        $last_results = Settlement::with('members')->whereHas('members', function($query) {
          $query->where('coordinator_id', '1');
          })->where('town_id', Auth::user()->town_id)
          ->get();

then in views in foreach loop variable '{{$settlement->name}}' working but '{{$last_results->last_results}}' not. That's what I don't understand because with dd() function a get same collection of arrays. Only with last_results it says:

Property [last_results] does not exist on this collection instance.

But, as you can see, it exist: https://ibb.co/DQcYTnG

Mar
17
2 weeks ago
Activity icon

Replied to Google Chart Not Working With Array, Just With Number

The thing that confuse me is that line working if it's just one number, and then is straight line. If it's more than one number (array in this case) that is suppose to be curved line like in that jsfiddle example than chart won't load.

For example, i did this in controller:

        $safe_voters = AddMember::with('settlement')->whereHas('settlement', function($query) {
          $query->where('reon_id', '1');
          })->where('town_id', Auth::user()->town_id)
            ->count();

        $members = AddMember::with('settlement')->whereHas('settlement', function($query) {
          $query->where('reon_id', '1');
          })->where('town_id', Auth::user()->town_id)
          ->where('cipher_id', '0')
          ->count();

        if ($safe_voters !== 0) {
          $percent_members = round(($members / $safe_voters) * 100,1);
        } else {
          $percent_members = "";
        }

and that variable {{$percent_members}} working in chart where it presents percentage in one line above chart bar.

Activity icon

Replied to Google Chart Not Working With Array, Just With Number

Now this appear: Undefined offset: 4

I hope that I didn't make typo anywhere but I don't think so...

Activity icon

Replied to Google Chart Not Working With Array, Just With Number

I did that then I get this error:

All series on a given axis must be of the same data type

This error was first thing that appear in my struggle with this. I manage that with changing datatype from integer to string.

Activity icon

Replied to Google Chart Not Working With Array, Just With Number

When I add ->toArray() this error appear:

htmlspecialchars() expects parameter 1 to be string, array given

Activity icon

Replied to Google Chart Not Working With Array, Just With Number

When i run dd($last_results); this shows:

https://ibb.co/0YwdjZn

and that numbers I need in google chart line.

Console log shows this: SyntaxError: expected expression, got '&'

Activity icon

Started a new Conversation Google Chart Not Working With Array, Just With Number

This is my google chart code:

   <script type="text/javascript">
    google.charts.load('current', {'packages':['corechart']});
    google.charts.setOnLoadCallback(drawVisualization);

    function drawVisualization() {
      // Some raw data (not necessarily accurate)
      var data = google.visualization.arrayToDataTable([
       [
         'Месни одбори', 
         'Капиларни',
         'Последњи резултат',
         'Очекивани резултат'
       ],

       @if ($settlements)

         @foreach ($settlements as $settlement)

           @if (($settlement->members->count()) > '0')

             [

               '{{$settlement->name}}',
                {{$settlement->members->count()}},
                {{$last_results}},
                {{$expected_results}}

             ],

           @endif

         @endforeach

       @endif

    ]);

    var options = {
      title : 'Реон1',
      seriesType: 'bars',
      series: {
        1: {type: 'line'},
        2: {type: 'line'}
      },
      colors: ['blue', 'red', 'purple'],
    };

    var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
    chart.draw(data, options);
  }
  </script>

  <div id="chart_div" style="width: 'auto'; height: 500px;"></div>

and this is my variables in laravel controller:

     $settlements = Settlement::where('town_id', Auth::user()->town_id)
      ->where('coordinator_id', '1')
      ->with('members')
      ->get();

    $last_results = Settlement::with('members')->whereHas('members', function($query) {
      $query->where('coordinator_id', '1');
      })->where('town_id', Auth::user()->town_id)
      ->pluck('last_result');

    $expected_results = Settlement::with('members')->whereHas('members', function($query) {
      $query->where('coordinator_id', '1');
      })->where('town_id', Auth::user()->town_id)
      ->pluck('expected_result');

Without variables $last_results and $expected_results working fine but when I add them google chart disappear. I have one more chart where is working fine but there are lines where is only one number, here is an array of numbers.