Category : foreach

$result = []; $items = $connection->query("SELECT * FROM `budget` WHERE `type` = ‘".$btype."’ ORDER BY `id` DESC"); foreach($items as $budget){ $arr[] = array( ‘id’ => $budget[‘id’], ‘type’ => $budget[‘type’] ); array_push($result, $arr); } echo json_encode([‘success’ => $result], JSON_UNESCAPED_UNICODE); it prints [object object], [object object], [object object], [object object] … Could you tell me why and ..

Read more

I’m trying to create a pagination in my search result. I have one queries in my repository like: public function getFilteredVehicles($id,$pax,$categories,$search_type,$from_date,$to_date) { $vehicles = Vehicle::whereHas(‘destinations’, function($q) use($id){ $q->where(‘destination_id’,$id) ->where(‘active’,1); }) ->paginate(1); if($search_type == ‘disposal’ || $search_type == ‘pnd’) { $vehicles = $vehicles->where(‘registered_location’,$id); } if($categories) { $vehicles = $vehicles->where(‘vehicle_categoryid’,$categories); } return $vehicles; } The returned result ..

Read more

I have 10 sets of numbers into array, representing different days. <?php $day1 = [’23’, ’11’, ’52’, ’33’, ‘1’, ‘4’]; $day2 = [’66’, ’70’, ’55’, ‘8’, ’22’, ‘1’]; $day3 = [’38’, ’21’, ’52’, ’51’, ’53’, ‘9’]; $day4 = [’14’, ’31’, ’54’, ‘5’, ’73’, ’39’]; $day5 = [’10’, ‘3’, ’22’, ’59’, ’73’, ’39’]; $day6 = [’22’, ..

Read more

tenho alguns resultados no banco e preciso alinhar eles de acordo com a imagem abaixo. Mas não sei nem por onde começar. Estou fazendo em Laravel 5.8. enter image description here <table style="border-collapse: collapse; width: 100%;" border="0"> <tbody> @foreach ($equipe as $key => $a) <tr> <td style="width: 50%;"> <p style="text-align: center;"><strong>{{$a->admin->name}}</strong></p> <p style="text-align: center;">Controladora Municipal</p> ..

Read more