Posts by Wallace Maxters • 102,340 points
1,984 posts
-
5
votes3
answers1083
viewsQ: How can I create a filter to fill with zero left at the angle?
I’m developing an application using Laravel and AngularJS. I always found it difficult to format a number to fill with Javascript zeros, so I chose to use Laravel to bring me the field number id…
angularjsasked Wallace Maxters 102,340 -
2
votes1
answer607
viewsA: Pass parameters using the guzzle client
The way to set the default parameter in Guzzle is using query. Behold: $client = new GuzzleHttp\Client([ 'base_uri' => 'http://example.com/', 'query' => ['foo' => 'bar'] ]); If you need to…
-
5
votes1
answer545
viewsA: How to install php-5 in Ubuntu?
After PHP has made the version 7 of stable PHP, it seems that the PHP PPA has changed and it is necessary to update it. sudo add-apt-repository ppa:ondrej/php sudo apt-get update Another important…
-
3
votes1
answer355
viewsA: Install Laravel 5.3 on Ubuntu 14.04.5 server
It is not installing because the Documentation of the Laravel 5.3 makes it clear: Laravel 5.3 requires PHP 5.6.4 or Higher. HHVM is no longer Officially supported as it does not contain the same…
-
3
votes2
answers221
viewsA: Use of methods in php object orientation
To do such action above, it would be necessary that tvs and pcs return a objeto who would have the method add. First option I don’t know if it would be more appropriate for you to use a method just…
-
2
votes1
answer47
viewsA: Why does the server not receive my data correctly?
On the server, it only recognizes the first request. Other order numbers do not appear. I have checked everything, which can be? To answer your question: This is wrong: <input type="text"…
-
4
votes2
answers109
viewsA: Searching in array using more than one word
Maybe you can make it with something like this: if(isset($_POST['palavra'])): $palavra = $_POST['palavra']; $separa = explode(' ', $palavra); $palavrasChaves = array("você", "bem", "?");…
-
51
votes1
answer7183
viewsQ: What is it and what is JWT for?
I saw in some comment here on the site, in some question, talking about JWT to solve an authentication problem. I had seen the term vaguely before and I thought it was something from Java (hehehe).…
-
2
votes1
answer902
viewsA: About Regular Expression in PHP - How to Get Part of a Text?
Wouldn’t it be better to use DomDocument? In my humble opinion, any recourse that already exists to solve a problem, that should be chosen. I think using regular expressions for cases like yours is…
-
1
votes1
answer420
viewsA: How to close uib-Popover by clicking out?
Searching Github back and forth, I discovered that it is an update problem. It was reported in one of the Issue, that this had been removed from version 1.3.3. However, when reading another issue,…
-
1
votes1
answer1023
viewsQ: Directive to detect click out of an element?
In Angularjs, we have the directive ngClick, which serves to perform an action when an element is clicked. I’d like to create a directive, called ngClickout so that when the click occurs outside the…
angularjsasked Wallace Maxters 102,340 -
1
votes1
answer420
viewsQ: How to close uib-Popover by clicking out?
I’m trying to utilize the uibPopover Angular UI Bootstrap to display a field input. The problem I’m having is that by clicking outside the Popover, it’s not closing. I’ve already looked for some…
-
4
votes2
answers5474
viewsA: Calculate day difference between two dates [PHP]
Use the method DateTime::createFromFormat to turn the date into an object DateTime from a format. Then use the method DateTime::diff to compute the difference between dates. $d1 =…
-
3
votes1
answer105
viewsA: How do I handle Variables in PHP?
First I’d like to point out some errors in your code, so we can look at the situation: $eqCodigo1 = explode("\n", $eqCodigos); // Isso vira um `array` $eqCodigo2 = array_filter($eqCodigo1); //…
-
4
votes1
answer3647
viewsQ: If Boolean('0') is true and Boolean(0) is false, why is '0' == false true in Javascript?
Why in javascript Boolean('0') is true, Boolean(0) is false, whereas when comparing '0' (a zero alone in the string) with false he returns true? Why would you behave? Example:…
-
7
votes4
answers7723
viewsA: Check for number in a string
Filter_var with FILTER_SANITIZE_NUMBER_INT A way to check whether the string contains at least one number, without using regular expression (which is usually slower), is using the function…
phpanswered Wallace Maxters 102,340 -
4
votes2
answers1805
viewsA: How to import the current $Scope to the $uibModal?
To do this, you need to pass the property scope as an option to $uibModal.open(). Just do it Just do it: $uibModal.open({ controller: 'ModalController', scope: $scope, }); This will make all the…
-
3
votes1
answer430
viewsQ: How to perform an action whenever $uibModal is closed?
How do I perform an action whenever the $uibModal is closed? Just to facilitate my learning, when I close the modal, I want to display a message. For example: angular.module('app',…
-
2
votes2
answers1805
viewsQ: How to import the current $Scope to the $uibModal?
I have the following modal in my controller: angular .module('app', ['ui.bootstrap']) .controller('AlunosController', function ($uibModal, $scope, MyPaginator) { $scope.alunos = new…
-
0
votes1
answer103
viewsA: uibModal does not show the items in ng-repeat
The error is in the section marked below: var modalInstance = $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'myModalContent.html', controller: 'ConsultaFiltroController', // Tá…
-
3
votes2
answers4492
viewsA: Is there any way to foreach two variables at once?
I know the question has already been answered, but I believe that the current answer only meets the cases where the first array contains only numbers or string. If you have a Object or Array,…
phpanswered Wallace Maxters 102,340 -
1
votes2
answers1760
viewsA: How to assign values to an associative array in php?
There is another way yet, which is by using reference. foreach ($arr as $key => &$value) { $value = 'novo valor'; } unset($value); // Tem que apagar, pois o último sempre fica como…
-
1
votes3
answers11941
viewsA: How to pass data from one input to another with html and javascript?
You haven’t mentioned which server-side language you’re using to process this data (or maybe you don’t even have one to cite). So the solution I would give to this would be to use localStorage. You…
-
4
votes3
answers108
viewsA: Instantiation of objects in php
In php it is not possible to store instances directly in the declaration of properties, as is done in C#. You can solve the problem by doing this in the constructor. class TesteUsuario { protected…
phpanswered Wallace Maxters 102,340 -
5
votes3
answers885
viewsA: How can I check if the last position of the array has been filled?
I would do so: $array = [1, 2, 3]; $end = end($array); if ($end) { echo "A última posição é {$end}"; } Note: The function end only works with arrays stored in variables, since it expects a parameter…
-
7
votes4
answers12782
viewsA: Validation of CNPJ with Angularjs
You can use a library called Ngcpfcnpj. Behold: <input name="cpf" ng-model="cpf" ng-cpf ui-mask="999.999.999-99" /> myForm.cpf.$valid: {{ myForm.cpf.$valid }}…
-
14
votes4
answers2450
viewsQ: What is the :: (two-point double) in Angularjs?
I saw that in some OS question in English an Angularjs code that was using double-points before the variable. Example: {{ ::nome_variavel }} The usual is: {{ nome_variavel }} What is the difference…
-
2
votes1
answer109
viewsA: Echo in real time
With php there is no way to do this "in real time". PHP is a server-side language (processes things on the server side), which will send a data output to the client (browser). After this output…
phpanswered Wallace Maxters 102,340 -
12
votes1
answer4323
viewsQ: What is the purpose of the JSON column in MYSQL?
I realized that Mysql has released a new feature, which is the column can have the type JSON (which can even be saved in binary, as I was reading). Documentation: As of Mysql 5.7.8, Mysql Supports a…
-
2
votes1
answer1643
viewsA: Update several records at once
For you to submit a form with multiple values, you need to write it as follows, to facilitate data allocation: {!! Form::open(array('method'=>'put', 'url' => url())) !!} @foreach($array as…
-
1
votes2
answers322
viewsA: How to compress the output of an HTML in Laravel?
To capture all HTML output of the application, you can also use a Middleware, who will take care of this pre-processing. First run the command: php artisan make:middleware HtmlCompressor Then leave…
-
3
votes2
answers322
viewsQ: How to compress the output of an HTML in Laravel?
I answered that question here once talking about the subject: Store PHP script output in HTML "compressed". But now I’d like to know how I can do it in Laravel. When it comes to an HTML response,…
-
0
votes2
answers2123
viewsA: Laravel checkbox checked or not checked according to Database
To do this, you first need to have the relationships properly configured in your model. For example: class Cor extends Eloquent { } class Produto extends Eloquent { public function cores() { return…
-
5
votes5
answers7569
viewsA: How to delete COOKIES in PHP?
The response of @Guillhermenascimento answers the question very well, but I would like to bring an addition. When it comes to Cookies, I don’t know if the right way would be to say "Delete Cookies".…
-
1
votes2
answers2205
viewsA: Nothing to migrate
When you run a Migration on Laravel, all records are recorded (by default) in the table migrations. It contains the information of which Migrations were executed. If you delete the table "in hand",…
-
20
votes7
answers21016
viewsQ: What does the term Fallback mean?
I’ve seen that term fallback used several times. Including framework that I use every day, the Laravel 5, that word appears in a certain configuration: Example: /*…
terminologyasked Wallace Maxters 102,340 -
8
votes2
answers1318
viewsA: python: compare list containing multiple lists with a different list only
I tried to do something as simple as possible. See: # -*- coding: utf-8 -*- from __future__ import unicode_literals respostas = [ ['a', 'b', 'c', 'd', 'e'], ['d', 'c', 'c', 'a', 'd'], ['d', 'c',…
pythonanswered Wallace Maxters 102,340 -
0
votes3
answers1027
viewsA: How to find out how long an audio is in PHP?
The answers are good, but they partly solve the problem. Actually, the question is not specifically related to MP3 files, but rather audio files (MP3, WAV, WMA, OGG and the like). Getid3 I was able…
-
3
votes1
answer134
viewsA: Problem running the Gulp
This happened to me directly. The solution I had was giving permission to the folder in which the gulp was not having access: cd pasta_do_projeto sudo chmod -R 777 . Another way I used to solve the…
gulpanswered Wallace Maxters 102,340 -
12
votes1
answer147
viewsA: Is there a magic method for calling an attribute as a method in php?
The magical method __call does that. Behold: class Foo { protected $bar; public function __call($method, $arguments) { return isset($this->$method) ? $this->$method : null; } } What is the…
phpanswered Wallace Maxters 102,340 -
5
votes2
answers1061
viewsA: Calculate the maturity date of the experience contract
With class DateTime, you can do so: $vencimento = (new Datetime())->modify('+45 days'); As you said that the user will enter the initial date, he will probably type this date in Portuguese format…
phpanswered Wallace Maxters 102,340 -
3
votes3
answers197
viewsA: Account with PHP in the order it is in the string
As a complement to the answer I have already given, I have decided to post a solution on the subject. There is a Symfony component called Expression Language, that can facilitate your service. With…
-
2
votes1
answer93
viewsA: Apache2 is not accepting PUT request method
I cannot explain exactly what caused the problem, but I have now solved this problem by simply installing the libapache2-mod-php5. Behold: sudo apt-get install libapache2-mod-php5 Now it’s working…
-
1
votes1
answer93
viewsQ: Apache2 is not accepting PUT request method
I tried to file a requisition for the guy PUT in a project of mine, but is being returned the following error: The requested method PUT is not allowed for the URL /index.php I’m using PHP to make…
-
1
votes4
answers1103
viewsA: Update with Laravel does not take model id
This is not an error. Actually, maybe the column name in the table or something else is wrong. The problem is being caused because Auth::user()->idusuario is returning NULL. For example, if you…
-
75
votes4
answers10585
viewsQ: What is database normalization?
I was talking to some programmer friends when I heard the term "database normalization". Although I’ve heard that term a few times before, I couldn’t understand what it was about. Some doubts have…
-
3
votes4
answers187
viewsA: How to not lose the "this" of the current object
Well, I don’t know yet why Javascript works like this, but I’ve had a lot of problems with it, when I try to, for example, simply pass the reference function as callback. I will show below one of…
javascriptanswered Wallace Maxters 102,340 -
7
votes3
answers3113
viewsA: Why is it mandatory to implement "public Static void main (String [] args)"?
Generally, in any programming languages, this parameter represents the input data that will be passed to your program. I don’t have much understanding about Java, although I have already tested it,…
-
3
votes2
answers412
viewsQ: How to find out what is the first or last item of the Loop in Laravel?
I got the following foreach in Laravel. @foreach($values as $value) <li>{{ $value }}</li> @endforeach I would like to add a special information when it comes to the first loop item. In…
-
8
votes1
answer719
viewsQ: What is the difference between "=" and "<" in the "Scope" options of a customised directive?
In Angularjs, I was creating a directive. I realized that by using the sign = to capture a certain controller scope value, when I changed this value, the parent controller value was also being…