Posts by novic • 35,673 points
1,265 posts
-
1
votes1
answer155
viewsA: Transform Mysql query into Eloquent (Laravel)
Basically: $subSelect = ' created_at IN '; $subSelect .= ' (SELECT MAX(created_at) FROM fundoloja_desocupacao GROUP BY grupo_id) '); $result = DB::table('fundoloja_desocupacao')…
-
0
votes2
answers658
viewsA: How to insert an array in a column of the Postgres array type with Laravel/Eloquent?
In the Eloquent does not yet have a plausible solution to work with this type of data array existing resource at the Bank PostGresql, that is to say, it does not support this yet, that including in…
-
3
votes1
answer63
viewsA: How to recover old values from select inputs?
To retrieve the chosen value after a request call the function old('tipo_id') and seeing its code was made the <select></select> at hand use a if within the option to set what was…
-
3
votes3
answers48
viewsA: Verification of repeated information in array
Use the function array_diff $primeiro_array = ["1", "2", "3", "4"]; $segundo_array = ["1", "2"]; $terceiro_array = array_diff($primeiro_array, $segundo_array); this way it will bring the expected…
-
0
votes1
answer129
viewsA: Google News API - Using Curl with PHP
I round up the test and the way your code is it gives an error message like this: SSL Certificate problem: Unable to get local Issuer Certificate then to get around that which is the verification of…
-
7
votes2
answers124
viewsA: Get the date of the first Tuesday of each month
For you to catch the next Tuesday starting each month utilize this tuesday, example: $dia = new DateTime(); $dia->modify( 'this tuesday' ); echo $terca = $dia->format('Y-m-d'); And to catch…
-
2
votes1
answer389
viewsA: Relationship of Laravel Relationship
IS as follows: Processo::with(['andamentos.fase'])->get() That is, the name of the separated relations by point and if you have other array. If you can change your Model to load all relations as…
-
0
votes1
answer74
viewsA: Update on some Laravel 4.2 fields
No need to bring all fields there is a way to do this by giving only the update in some defined fields: Example that is in the documentation DB::table('users') ->where('id', 1)…
-
2
votes2
answers1849
viewsA: Create Controller in a specific folder in Laravel?
Wraps double folder quotes and controller that works: $ php artisan make:controller "Utils\SpaceController" --resource where Utils is a folder created and the SpaceController own controller.…
-
1
votes1
answer25
viewsA: how to make an input field appear only when it is two hours above the current time?
If you can do it like this: function dateDifference($date_1 , $date_2 , $differenceFormat = '%h' ) { $datetime1 = date_create($date_1); $datetime2 = date_create($date_2); $interval =…
-
1
votes2
answers45
viewsA: Problems with Join Laravel ORM
Basically the code below solves, the observation is that within where can’t make a join always separate using the latest version of the builder making the criticisms and passing the new value to the…
-
3
votes2
answers52
viewsA: How to search for specific data on the same line?
Create a class to serve as a template to store the items in this XML, example: public class Rows { public int GenericKitName { get; set; } public int QueryID { get; set; } } and the code to be…
-
4
votes4
answers190
viewsA: Divide a sentence into 2
A very basic solution: <?php $frase = 'Nome do produto teste cadastrado'; $partes = explode(' ', $frase); $quant = count($partes); $div = ceil($quant / 2); $items = array_chunk($partes, $div);…
-
2
votes2
answers243
viewsA: Aggregation of Codeigniter objects 3
First, it would create two models representing each table, in its specific case Tickets and Solicitantes as follows: Inside the folder application creates another folder named after entities (the…
-
1
votes2
answers470
viewsA: How to use namespaces without classes with autoload from Composer?
This type of implementation is corresponds to the folder organization, the namespace should have the same path as your folder, which is not what happens in your question, the correct would be to…
-
0
votes2
answers109
viewsA: Extracting Infos from an external JSON by php
Using Curl, being a library for communication of several servors and also several protocols, the contents of this address are downloaded in the format json: { "fan_count": 185, "id":…
-
2
votes1
answer88
viewsA: Laravel 5.7 - Side bar control via Controller
The technique created to do this is with Viewcomposers which are data that can be shared in several Views of its one-place system. The Viewcomposers is a way to create only one data return and send…
-
1
votes2
answers302
viewsA: Combine arrays within array
First search the repeating keys that in the case is title, then its numerical indexes of the array with the data and then join them with array_merge, example: <?php $arrayTable = array( 0 =>…
-
0
votes1
answer33
viewsA: How to list EXC exchange information via API in PHP?
In this part of the code you forgot to specify the result where I believe the collection of information: JSON: {"success":true, "message":"", "result":[{ "Market":"DCR_BTC", "Bid":0.00452230,…
-
4
votes2
answers44
viewsA: Working with Array in PHP
With a simple function it is easy to solve this problem, example: <?php $array = array( array("0000000009999999","20181209","000000","REM BASICA","0.00","C"),…
-
2
votes2
answers262
viewsA: Return array of properties in the Laravel
To return only one field use the method select (or even selectRaw`) and bring only the field(s) (s) on the return of the Builder, example: public function avisarAnjos(Request $request) {…
-
1
votes1
answer115
viewsA: I can’t make research work with eloquent and relationship!!! Laravel 5.5 and mysql
Utilize whereHas to check the relationship data and with with load data from the relationship between entities, example: $pesquisa = $dataForm['pesquisa']; $atestados =…
-
1
votes1
answer58
viewsA: I can’t get into the foreach of a Lade at Laravel 5.7
You are not returning a collection, you are returning a simple dice, remove the foreach and put a if, example: <div class="form-group"> {!! csrf_field() !!} @if(isset($impressora)) <div…
-
1
votes3
answers1141
viewsA: Laravel - How to Page and Give Order By
Avoid doing so, only a few cases: $modeloVideo = ModeloVideo::all()->orderBy('created_at', 'desc')->paginate(10); because, you’re bringing in the all() all records in the database in a…
-
0
votes2
answers455
viewsA: Laravel - How to call several methods passing the same route?
You cannot write the same route for two or more controller and métodos different. Each route that is configured is also unique within the project, but other than that it can write several different…
-
2
votes1
answer793
viewsA: Set value inputmask jquery
I understand your problem, because when you send a point value, example: 150.6 consider R$ 1506,00 and should be: R$ 150,60, then it has to set correctly as follows, changing the point by comma in…
-
2
votes1
answer438
viewsA: Get data return xml
A solution is with Xdocument from the namespace System.xml.Linq, example: XNamespace ns = XNamespace .Get("http://www.betha.com.br/e-nota-contribuinte-ws"); string soapResult =…
-
1
votes1
answer370
viewsA: Form::select Orange
First, the die has a traffic of Controller for View and vice versa, but never the View generate this information directly, example of modification of your Controller method: public function create()…
-
5
votes1
answer385
viewsA: Self Relationship with Entity Framework 2.2
The auto relationship setting is as follows for your class Menu: x.HasMany(k => k.SubMenu) .WithOne() .HasForeignKey(k => k.MenuId) .HasPrincipalKey(k => k.Id); that is, it must inform…
-
0
votes1
answer129
viewsA: How to redirect to an action on Asp.net mvc, using jquery?
There are some examples here on the site, and the command is window.location.href passing the value of the address, example: $("#Filtro").change(function () { window.location.href =…
-
1
votes1
answer1087
viewsA: Serialize XML for special characters
It may be that this solution is not the fastest, but it solves the problem satisfactorily, because it is a solution with reflection (Reflection): Create a class that are two extension methods with…
-
0
votes1
answer193
viewsA: Display file data . env in Blade
Just put the name of the key that is in the file .env, example: APP_ENV=local APP_KEY=base64:M2eN0OPMVR/CDoUSlI+bZW1sgqgmkqC/l7R8omQx8Dc= APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL=http://localhost…
-
2
votes1
answer363
viewsA: Consultation Eloquent select total
Just put estabelecimento_id in his SQL and by the forward charge ratio take the descricao table estabelecimento, example: $totais = Pedido_cliente::with('estabelecimento')…
-
1
votes1
answer250
viewsA: How do I mount a select with two fields using colletivehtml in 5.5?
Do with the command CONCAT Mysql to merge fields and method selectRaw of Builder Eloquent to write a select like that: Local::selectRaw("id‚CONCAT(codigolocal,' ',descricaolocal) as…
-
5
votes3
answers98
viewsA: With LEFT JOIN list the NOT IN
Do with Leftjoin to search all record of the table on the left and with this the ones that do not have on the right side can be brought with IS NULL which is the data that has no relation to the…
-
0
votes1
answer53
viewsA: Search and bring id from another table
When you need to do a type of search that has a relationship, use the method Join of the Query Builder as follows: public function busca(OrdemRequest $request) { $problema = $request->problema;…
-
2
votes1
answer192
viewsA: Save XML without formatting
See you are confused the classes, the one you are using by the method parameter is XmlDocument that does not overload with the parameter SaveOptions, but, there is a way to save the XmlDocument…
-
0
votes1
answer81
viewsA: Do I need to return the client’s name in the View orders?
In the model Ordem add the relationship with the model Cliente as follows: $this->belongsTo(Cliente::class,'cliente_id', 'id'); Observing: this link has the explanation of how to configure…
-
3
votes2
answers155
viewsA: Perform action before saving?
Yes there is the part of events that consists of a class that generates some or some modifications before the event for example to save, in your code example can be used a creating so that before…
-
8
votes2
answers555
viewsQ: Command SQL PARTITION BY?
I am reading and it was not very clear the command PARTITION BY in the creation of tables in structured databases (SQL), a basic example: CREATE TABLE employees ( id INT NOT NULL AUTO_INCREMENT…
-
3
votes1
answer903
viewsA: Sort JS Object array
I already created the function to sort by age, I gave a console log and is ordering my question is how do I order only when you click the button It seems that its difficulty is to call the function…
javascriptanswered novic 35,673 -
0
votes1
answer841
viewsA: Laravel 5, assuming variable in empty query?
When using the Query Builder to rescue information from tables in your database the result is always a Collection belonging Illuminate Support Collection, summing up is a class. Whether this…
-
2
votes1
answer56
viewsA: Problem when deserialize json with $
You need to configure in the classes in their properties JsonProperty (which can set for example the key name of the JSON) of as follows: public class Rootobject { [JsonProperty("_id")] public Id Id…
-
1
votes1
answer99
viewsA: Truncated data for the vlrDesconto Laravel column
Truncated data, is because, the value passed is higher than what is configured in the database and also needs to convert the value that is in the Brazilian format to American, example:…
-
0
votes2
answers342
viewsA: How do I store 0 or 1 of a checkbox?
The input checkbox when it is not selected does not pass value and how to resolve it in Laravel? In the method $request->input pass the second parameter which is the default value, example:…
-
4
votes2
answers169
viewsA: How to list the log of a local GIT repository through PHP?
Basically the command inside the PHP exec('git log', $result); print_r($result); outworking: Array ( [0] => commit 693673def6d3cb8f196cf5988af70b87c4ff4cb3 [1] => Author: None…
-
1
votes2
answers39
viewsA: Popular column with created id + date/time
By comments and with a simple option you can do as follows after this code just below add: //Insere Formulário no Banco $insert = $this->manifestation->insert($dataForm); if ($insert) // se…
-
3
votes1
answer149
viewsA: Error sending form with if:Lse in the Standard
The method does not exist because you used ->extension() the wrong way, the right way would be: if ($request->hasFile('upload')) { $ext = $request->upload->extension(); } I might still…
-
3
votes1
answer282
viewsA: Upload Image, and Create a Thumb of the same Asp.Net Mvc Image?
Create a method with the following code referring to the question: https://stackoverflow.com/questions/27921/what-is-the-best-way-to-create-a-thumbnail-using-asp-net using ( Image bigImage = new…
-
3
votes1
answer729
viewsA: Help Update Laravel
No need to pass the id in the verb post, you just need to create a input hidden and save value id in this field, but, if you still want the way you did you need to pass the tag form the id because…