Posts by Kayo Bruno • 2,777 points
137 posts
-
3
votes3
answers89
viewsA: With putting together a query on Eloquent?
You can do this in two ways, the first would be using the Model of this table and the second would be using the facade DB In the case of this second option, the. // Exemplo utilizando model $valor =…
-
1
votes1
answer42
viewsA: Error in this PHP code generates null or empty strings
The function is not working because you put the variable $ref outside the scope of its functions. You can place it within the function encode() or pass it as a parameter. function encode ($string) {…
-
4
votes3
answers480
viewsA: How do I know and count the number of rows in an SQL query with Laravel?
You can use the method count() $teste = DB::table("cnaes") ->select("id") ->where("cnpj", $cnpj) ->where("cnae", $cnae) ->count();…
-
2
votes2
answers33
viewsA: List array within exceptions (IF) and generate new status array
If I understand correctly, what you want to do is simple, just you assign the status setting the position of array. $status = []; // Usei o count para pegar o tamanho total do array e não precisar…
-
0
votes1
answer47
viewsA: How to reopen an order that has been canceled
By default there is no route in the API to "undo" an order cancellation in Magento, but it is possible to create custom routes, so you can create your route to undo a cancellation. In the…
magentoanswered Kayo Bruno 2,777 -
2
votes1
answer1590
viewsA: ERROR: POST.... 500 (Internal Server Error) - LARAVEL and AJAX
You need to pass the value of $peoples to the View. public function tbody() { $peoples = People::all(); // Exemplo se for pegar os dados do banco. return view('peoples.tbody', ['peoples' =>…
-
0
votes2
answers626
viewsA: Laravel and Json Web Token
You can make a overwrite in the method getCredentials() /** * Get the needed authorization credentials from the request. * * @param \Illuminate\Http\Request $request * @return array */ protected…
-
0
votes2
answers104
viewsA: how to validate lines from a csv file not to go empty to the database
You can try this way: <?php require_once('csv.php'); require_once('db.php'); class Main { public function process($dados){ $delimitador = ';'; $cerca = '"'; $csv = new CSV ();…
phpanswered Kayo Bruno 2,777 -
0
votes1
answer113
viewsQ: Merge PNG/JPEG with GIF using PHP
I need to make a merge of an image in PNG/JEPG with some gifs and save the end result as GIF. I can do that merge with the code below, the image is saved as gif but it turns out that gif loses…
-
1
votes1
answer57
viewsA: Help with PHP session
I think you can do as follows, in your query session you will store an array of queries and not just a query. Whenever you make a new query, you take the value of your session, increment the new…
-
0
votes2
answers286
viewsA: Dynamic URL in the Laravel
I think the ideal is for you to work with slug, that one library can help a lot with this, it generates slugsfrom any field you set up and she still makes the treatment for the slugbe unique.…
-
0
votes2
answers232
viewsA: Doubt with set value (codeigniter)
You just use the set_value in the 3 function parameter form_dropdown. In your example you put null. echo '<div class="form-group">'; echo form_label('Tipo de Produto: *', 'tipoproduto'); echo…
-
0
votes3
answers558
viewsA: Display only part of the text in an Html page
Depending on the version of Larable that you are using, there is a helper for this called str_limit(). More information here $text = 'Lorem Ipsum is simply dummy text of the printing and typesetting…
-
0
votes2
answers49
viewsA: Error running mysql php query
As already commented all the columns that are in your SELECT need to be in your GROUP BY. If you don’t want to do this you can disable the sql_mode. mysql > SET GLOBAL sql_mode=(SELECT…
-
0
votes1
answer16
viewsA: How to link pages Word Press Theme Creation
In wordpress you must create a file pages.php as default page, this file will be used to render all pages you create in wordpress admin. If you need a unique template for any page you need to add a…
-
2
votes1
answer984
viewsA: Obtain approach radius from a geographical coordinate
You will solve this using this library to the Laravel, she works with spatial data types on Mysql. This library has several methods for working with coordinates, polygons, distance and etc. After…
-
0
votes1
answer42
viewsA: Controller show method intercepting route without parameter
You are using the verb GET and so is being redirected to the method show, change to POST. Route::post('/galleryCategory/create/{category?}',…
laravelanswered Kayo Bruno 2,777 -
2
votes1
answer794
viewsA: Customization of Fields Login Laravel
You can make a overwrite in the method getCredentials() /** * Get the needed authorization credentials from the request. * * @param \Illuminate\Http\Request $request * @return array */ protected…
laravelanswered Kayo Bruno 2,777 -
1
votes1
answer53
viewsA: Interval in PHP execution
You can use the function sleep() of PHP. It takes as parameter the amount of seconds. But I advise you to search for a way to implement Queues in its application. $sql_1 = "SELECT * FROM `tbl` WHERE…
phpanswered Kayo Bruno 2,777 -
0
votes2
answers399
viewsA: How to make a @foreach with Relationship Tables in Laravel
The problem is that you related wrong in your Model. You changed the order of the parameters. public function tipoacao(){ return $this->hasMany( TipoAcoes::class, 'tipoacao_id', 'id'); // 1º…
-
1
votes3
answers144
viewsA: Doubt - Array php return
In the PHP the "." point is used for concatenation and not for referencing attributes of an array. To reference an associative array property you need to pass the property name. $teste =…
-
0
votes3
answers1090
viewsA: array in a php foreach
A simple way to solve this: <?php foreach ( $modelo as $k => $v ) { $sql_ = "SELECT * FROM pedido WHERE modelo LIKE '%".$v."%' ORDER BY id ASC"; $disp_sql_ = $mysqli->query( $sql_ );…
-
10
votes3
answers334
viewsA: What’s the difference between throw and Alert
In fact the statement throw doesn’t work the same at the alert, what it does is to cast a user-defined exception, and all it has after the throw will not be executed. And the control will be passed…
javascriptanswered Kayo Bruno 2,777 -
1
votes1
answer391
viewsA: How to recover data from checkbox as "checked"?
I will try to explain in a simple way, how you should do to be able to use the Sync method(). The Model below will be responsible for your table 'checklist_items'. class Item extends Model {…
-
1
votes1
answer58
viewsA: Question about <button></button>
The way you want to do I do not consider it a good practice, you should not run the functionality on view, that is the responsibility of controller. Then you can do as follows, in your comments…
-
1
votes1
answer47
viewsA: Function authorizing or not form Ubmit
The code below can solve your problem. $('#FornecedorNovo').submit(function (e) { e.preventDefault(); // Coloca o preventDefault no início da função var url = "/Fornecedor/VerificaInscricao"; var…
-
0
votes1
answer84
viewsA: Sort by custom Fields and by publication date
You can make this ordination on Wordpress as follows: $args = array( 'post_type'=>'colecoes', 'orderby'=>'date', 'order'=>'DESC' ); // order pode ser ASC ou DESC $query = new WP_Query(…
-
0
votes2
answers44
viewsA: Error using Many to Many
To define the relationship Many To Many it is necessary to have 3 tables, in your case would be: users, people and personal. The 3 table should follow the pattern of alphabetical order. In the Model…
-
1
votes1
answer33
viewsA: How to show this year’s posts in Wordpress
You will achieve this by following the example below: // O parâmetro "year" vai trazer somente posts do ano informado. query_posts( array( 'post_type' => array('episodes'), 'showposts' =>…
-
4
votes1
answer26
viewsA: What is the difference between a documented function and a single argument list?
The difference is that a documented function has all the information you need to use it. For example: necessary arguments, what the function returns, examples of how to use the function, possible…
-
1
votes1
answer50
viewsA: Make Wordpress direct an access to a PHP file in the theme
You just create one page template with the file "diagnostico-de-processos.php". You just need to put the following comment at the beginning of the file: /** * Template name: Página de Diagnósticos…
-
0
votes1
answer96
viewsA: Error 1054 Orange
You are passing the "page" parameter in your query, this happened because of the way you did using a foreach to go through all fields of request and playing every field in the consultation. The code…
-
-2
votes1
answer165
viewsA: Decrease php hours
I couldn’t understand very well what you want, but if you need to calculate the difference between dates, you can use the class Datetime of PHP. <?php $data_one = new DateTime( '2018-06-11…
-
3
votes1
answer57
viewsA: send login information to the bank for comparison
You can use the authentication itself Laravel already offers. At the beginning of your controller give a "use Auth;" to use the class Auth inside your controller. public function authenticate() { if…
-
0
votes2
answers56
viewsA: How do I get all 60 numbers
You will need to create a method get that will return $this->codes public function getCodes() { return $this->codes; }
phpanswered Kayo Bruno 2,777 -
1
votes0
answers453
viewsQ: Round decimals with PHP
I need to round decimal numbers down, except for when the decimal place is 5, for example 1.2 I want to round off to 1 and when the number is 1.5 I want to keep the value. I know only 3 functions of…
-
0
votes3
answers701
viewsA: (Laravel) How to ignore null values in $request->all()?
Man unfortunately the $request of Laravel has no method that can help you, but it can be solved well with the function php array_filter. The function array_filter filters elements of an array using…
-
7
votes2
answers111
viewsA: Change pennies of values
I think you can do it this way: jQuery(document).ready(function() { $('#mudarCentavos').click(function(){ // Recebe o valor input var centavos = document.getElementById('getCentavos').value //…
javascriptanswered Kayo Bruno 2,777 -
0
votes3
answers1209
viewsA: Sum hours of an array
You can create a function to do this treatment, and just call it at the end of your loop. function convertTime( $total_hours ) { $hours = floor( $total_hours / 3600 ); $minutes = floor( (…
-
7
votes1
answer11610
viewsA: Wherein no Eloquent
According to the documentation of Larable, the "wherein" method should receive an array as a parameter, even if it is only a value. $result = DB::query()->select( 'permissao' )…
-
8
votes2
answers322
viewsQ: What is the HTTP verb I use for logout?
I have a logout endpoint to make the Current user token invalid. With this came a question: Which HTTP verb should I use to log out?
-
0
votes1
answer266
viewsA: Automatic character insertion in a form to validate CPF
Download this lib (http://www.geradorcpf.com/jquery.maskedinput-1.1.4.pack.js) and use as follows: <script type="text/javascript" src="js/jquery.maskedinput-1.1.4.pack.js"/></script>…
-
2
votes1
answer700
viewsA: Pick all dates of a day of the week
Try it this way: function dias($dias_semana, $mes, $ano) { $date = new DateTime(); $dias = cal_days_in_month(CAL_GREGORIAN, $mes, $ano); for ($dia = 0; $dia <= $dias; $dia++) { $date->setDate(…
-
1
votes1
answer102
viewsA: How to filter a list using the same parameter with two different values?
The problem is that you are using the same field several times to receive different values. One way to solve this is to use only one field receiving all values separated by some character. For…
-
3
votes1
answer46
viewsA: Sort numbers on a Sept?
Do the following, turn this string into an array, then sort the array the way you want, and finally convert the array into a string separated by the character you want. $_SESSION['numbers'] =…
phpanswered Kayo Bruno 2,777 -
1
votes2
answers42
viewsA: Create a name for a variable with php
First you create the array then you assign the values. // Cria o nome da variável $tabela = "tabela1"; // Cria o array $$tabela = array(); // Atribui os valores $$tabela[1] = array( "valor" =>…
phpanswered Kayo Bruno 2,777 -
1
votes1
answer69
viewsA: Query data in different arrays for reporting
You can use the "cod_prod" field to resolve this. In the value loops and promotions, instead of you always assign the array to a new position, you will inform the key that will be the product code,…
-
2
votes1
answer89
viewsA: Placing delete method inside a Jquery append
You can do this using Ajax, which will be triggered in a delete button click event, and in it you will get the ID of the item you want to remove as parameter. <script>…
-
5
votes2
answers4088
viewsA: Getters and Setters Methods
The methods getters and setters are methods for access and modify information of classes that have encapsulation. You can put whatever name you want in the function, but this is already an…
-
1
votes2
answers541
viewsA: How to separate string in array?
You can do it like this: $cat = $_POST['categoria']; $sql = "SELECT DISTINCT descri_produto, cat_produto FROM produtos WHERE cat_produto LIKE '".$cat."'"; $result = mysqli_query($conn, $sql); $data…