-2
I’m struggling with something relatively simple, but it’s causing me a headache because I always get error.
In an application I need to get the amount of open classes coming from the Crud of Classes. It was to show the number of classes with open status that in this case are 6, but I’m not able to implement this to appear on Dashboard. I can only set the value manually, in this example I put as 40, someone can help me?
Canvas:
And here’s the excerpt from the code:
@extends('layouts.app')
@section('content')
<div class="row">
<div class="col-lg-6 col-xs-12">
<!-- small box -->
<div class="small-box bg-yellow">
<div class="inner">
<h3>40</h3>
<p>Turmas Abertas</p>
</div>
<div class="icon">
<i class="ion ion-person-add"></i>
</div>
<a href="treinamentos" class="small-box-footer">Veja Mais <i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">Turmas com status <strong>Aberta</strong></div>
<div class="panel-body table-responsive">
<table class="table table-bordered table-striped ajaxTable">
<thead>
<tr>
<th><center> @lang('Nome do Treinamento')</th>
<th><center> @lang('Data de Inicio')</th>
<th><center> @lang('Data de Conclusão ')</th>
<th><center> @lang('Situação da Turma')</th>
<th>Ações<center> </th>
</tr>
</thead>
@foreach($treinamentos as $treinamento)
@if($treinamento->situacao_turma == "Aberta")
<tr>
<td><center> ? </td>
<td><center>{{ $treinamento->data_inicio }} </td>
<td><center>{{ $treinamento->data_conclusao }} </td>
<td><center>{{ $treinamento->situacao_turma }} </td>
<td><center>
@can('treinamento_view')
<a href="{{ route('admin.treinamentos.show',[$treinamento->id]) }}" class="btn btn-xs btn-primary">@lang('quickadmin.qa_view')</a>
@endcan
</td>
</tr>
@endif
@endforeach
</table>
</div>
</div>
</div>
@endsection
Imagery:
CONTROLLER CODE:
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$cargos = \App\Cargo::latest()->get();
$setores = \App\Setore::latest()->get();
$turmas = \App\Turma::latest()->get();
$treinamentos = \App\Treinamento::latest()->get();
return view('home', compact( 'cargos', 'setores', 'turmas', 'treinamentos' ));
}
}
I have classes, with open and planned status. I wanted to take only the classes that have open status in the $situaca_turma variable and display the total amount on Dashboard
– Allan Sampaio
I understand Allan, but do it >
print_r($treinamentos)
just so I can see this object.– Andrei Coelho
Returned on the screen exactly the: 'print_r($trainings)', was this or am I doing something wrong?
– Allan Sampaio
Try it this way:
{{print_r($treinamentos)}}
– Andrei Coelho
That way he returned me all the records I have registered in my table classes, nor could I post here because exceeds the character limit
– Allan Sampaio
Put the records in the question, edit it... and put there
– Andrei Coelho
I edited and placed the records
– Allan Sampaio
Blz, I’ll take a look
– Andrei Coelho
I thank you for helping me
– Allan Sampaio
I think I figured it out. We’re gonna have to test.
– Andrei Coelho
Massa, I’m on
– Allan Sampaio
Delete the list you posted!
– Andrei Coelho