Category : laravel-5

I have the following Laravel collection $output. I want to sum total for each value of sex 1 and 2. I have tried $output->sum(‘total’) but it gives overall total . IlluminateSupportCollection {#1334 ▼ #items: array:11 [▼ 0 => {#1348 ▼ +"total": 1037931027.8459 +"status": 2 +"sex": 1 } 1 => {#1346 ▼ +"total": 1091237622.0488 +"status": 2 ..

Read more

I have a big problem to transform CURL to Http facade in laravel. So I have the code : $httpParams = [ ‘textData’ => $xml->asXML(), ‘xmlFile’ => new CurlFile($params[‘file’]->getPathName()) ]; $curlHandle = curl_init(‘http://url.com’); curl_setopt($curlHandle, CURLOPT_HEADER, false); curl_setopt($curlHandle, CURLOPT_POST, true); curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $httpParams); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); $curlResponse = curl_exec($curlHandle); curl_close($curlHandle); dump($curlResponse); die(); I have the xml ..

Read more

private function getBrandIdFromName($brandName){ $brand = Brand::query()->where(‘slug’,$brandName)->filter($brandName); if($brand){ return $brand->id; }else{ $newBrand = [ ‘name’=>$brandName, ‘is_active’=>"1", ‘meta’=>[ ‘meta_title’=>null, ‘meta_description’=>null, ] ]; $brand = Brand::create($newBrand); return $brand->id; } } I use first() to check first text in string but i want to check whole string. what is method to do this? suppose i have word "hello world" ..

Read more

So I’m using Laravel eloquents to access data from my database – it’s very similar to other statements in my code which work fine, but for some reason this isn’t working: $data->leftjoin(‘val_keys’, function($leftJoin) use (&$key_words) { $leftJoin->on(‘val_keys.val_id’, ‘=’, ‘vals.id’); })->whereRaw(DB::raw(sprintf(‘(LOWER(val_keys.key) LIKE "%%%s%%")’, strtolower($key_words)))); I keep getting the following error, which shows that there is a ..

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