Posts by juniorb2ss • 2,503 points
63 posts
-
2
votes2
answers57
viewsA: Error in Laravel 5.0
Not configured there. Settings are in the file .env, if it does not exist, rename the file .env.example for .env, inside the file will contain the variables: DB_CONNECTION=mysql DB_HOST=127.0.0.1…
-
3
votes3
answers701
viewsA: (Laravel) How to ignore null values in $request->all()?
You can use the helper array_where. Example: $a = ['a' => 'b', 'c' => null]; $filtered = array_where($a, function($value, $key){ return !is_null($value); }); // ['a' => 'b'] This way will…
-
3
votes2
answers3137
viewsA: Sum a date and a number x of months
In a way, it’s simple. Following the logic: Add up the amount of months, soon after catch last day of the month. // Data de ínicio $date = (new DateTime('2017-10-01')); // Adiciona 2 meses a data…
phpanswered juniorb2ss 2,503 -
3
votes1
answer731
viewsA: Pick up and list months between dates of different years
Following example: // Data de ínicio $start = (new DateTime('2017-10-01'))->modify('first day of this month'); // Data final $end = (new DateTime('2018-10-01'))->modify('first day of next…
-
0
votes2
answers7073
viewsA: Put If to Where
For conditions, the expression CASE. For example: SELECT CASE WHEN 1=1 THEN 1 ELSE 0 END In this query: CASE the condition of 1 be equal 1 the exit will be 1, being contrary 0. Using case you can…
sqlanswered juniorb2ss 2,503 -
1
votes1
answer95
viewsA: Phpmailer: Using the email field as the sender
No need to put the email as the sender. You can use the function replyTo for this. It is intended that when the email is answered by the mailbox, the reply goes to the email informed in the function…
-
1
votes1
answer50
viewsA: How to iterate to get all results of xpath->evaluate
You will get the result this way: <?php $dom = new DOMDocument; $dom->loadHTML('<div class="xGh" style="background-image: url(\'name_file.jpg\');"></div><div class="xGh"…
-
1
votes1
answer67
viewsA: Is it possible to get the value of the background-image attribute through xpath?
Yes, it is possible. The code path is correct, it is only necessary to fix the syntax and xpath. <?php $dom = new DOMDocument; $dom->loadHTML('<div class="xGh" style="background-image:…
-
1
votes1
answer78
viewsA: Restricted access to files with Git
Let’s go by part. First of all, it is not interesting files with sensitive data walk in versioning, for example settings could be made using this library: https://github.com/vlucas/phpdotenv Now, if…
phpanswered juniorb2ss 2,503 -
1
votes1
answer203
viewsA: Send two txt fields via Soap using PHP
Just read the contents of the file using file_get_contents and traverse the lines by breaking \n and also ;. $txtContent = "1;1\n2;2\n3;3"; // file_get_contents('file.txt'); $arrayContent =…
-
0
votes2
answers2217
viewsA: Download Nfe / NFEPHP
Felipe, stick to the technical standard NT 2014.002.v.1.02. Where is clear in the quote: Date of deactivation of Web Services Nfeconsultadest and Nfedownloadnf: 02/05/2017; Therefore, both services…
-
1
votes1
answer290
viewsA: How do I solve this problem of method create in Laravel
Problem is you pass the entire request collection to mass assignment of the create method, so it transforms the instance of the Uploader file into a string, returning the path. Replace the image…
-
2
votes1
answer904
viewsA: HTTP request limit and SQL queries
Well, come on! Memory, processor or disk is not everything When it comes to infrastructure, having a strong processor, a disk drive with high I/O or up to 64gb of memory may not support large…
-
2
votes2
answers944
viewsA: How to insert an item into a particular php array position?
Why? First, why you need it in a certain order since your array is associative? Now, if you need it to be in the correct order, you can use the function array_splice, see example: <?php $array =…
-
3
votes1
answer225
viewsA: What are the "partials" folders in Laravel?
Partials lives up to the term "partial", which refers to "partial views". Suppose you have a body, in this body you own: top header, banner, menu and content. top header, banner and menu would be…
-
5
votes1
answer357
viewsA: Request by date
William, to be able to sort by date the field evento it is necessary to be with the type datetime. If the field is of the string type, you will need to convert this date to a date instance and thus…
-
5
votes2
answers2344
viewsA: How to print directly without opening the browser dialog box?
Direct response: No, it’s not possible. Imagine it was possible, you visit a website unintentionally start printing unwanted things on your printer without your permission, already imagined? Who…
-
-1
votes1
answer188
viewsA: Update with hasMany relationship for two inputs at the same time in Windows
The update method expects an associative array as parameter. Take a look at the documentation: https://laravel.com/docs/5.1/eloquent#basic-updates So the correct method of doing the update is:…
-
1
votes3
answers708
viewsA: How to check the return of a function
You need to review the library you are using, take a look at its documentation and see the return of send(). However, if you are using PHPMailer which it is customary to use you can observe here:…
-
1
votes2
answers481
viewsA: Xmlhttprequest (Ionic + Laravel) error
Speak Eduardo, all good? The package Laravel Cors really has a bug! Calm down that it is not you that is getting crazy... We had this problem recently in an application, in angular coupling with…
-
2
votes1
answer1551
viewsA: Laravel - List with list of tables (state/city=>person)
Good, come on. First let’s impose some doubts as to its logic and if possible some corrections. Contato hasMany Estados In free translation this saying: Contact contains several States. That is…
-
2
votes2
answers224
viewsA: Display content (only once) after X repetitions in PHP
Just check which one I skip this loop. Go through the amount needed, with a if you check which current level and execute what you want. <?php $nivel = 1; // vamos começar pelo nível 1 while…
phpanswered juniorb2ss 2,503 -
0
votes2
answers142
viewsA: How can I format this array to the way I want it?
There’s no escape from the loop. Basically you will go through the first puzzle, picking up the level. Each level should take the permissions and so map a new array with the new format. Follow an…
-
1
votes1
answer354
viewsA: How to Dump in Mysql for the file to contain the date?
Just create a shell script to back up for you. https://gist.github.com/juniorb2ss/3661141de3a0dbbeaa5b30c34d0062a7 Basically to get date just use: /bin/date +%d-%m-%Y Rest just run the dump and save…
-
0
votes1
answer28
viewsA: Question about "->"
It will receive the return of the method query(). Simply that. It depends on the scope of your class, whether this method is return __toString or etc. It is possible to make return of the class urge…
-
2
votes2
answers648
viewsA: Record Multiple Numbers in a Field in the Database
Use JSON format field. Support Mysql for JSON format, which is perfect for your purpose. Basically: You will capture the numbers, put in an array and convert to JSON, after that will save in the…
-
2
votes1
answer265
viewsA: What is the KEY used in frameworks for?
Is used to SALT hashing in PHP The Laravel works on library password_hashfor generating keys protected in passwords. Check out: Illuminate\Hashing\BcryptHasher line 30 public function make($value,…
-
5
votes2
answers318
viewsA: How to echo a variable of this function?
You can transform the way you store the variables. function armazena_constantes (){ $array = []; $array['path'] = '/home/axitech/www/dent'; $array['path_admin'] = '/home/axitech/www/dent/admin/';…
phpanswered juniorb2ss 2,503 -
1
votes2
answers477
viewsA: Invalid URL server error 500
You can customize the errors yes. ErrorDocument 500 "Sorry, our script crashed. Oh dear" ErrorDocument 500 /cgi-bin/crash-recover ErrorDocument 500 http://error.example.com/server_error.html…
-
4
votes2
answers2954
viewsA: Hide URL data and change display
The problem of leaving so is that, anyone can arrive and enter an ID at the end and access other information. Let’s start over here. First of all this is a safety factor, not a visibility factor.…
-
10
votes2
answers2742
viewsA: How to backup the database to cloud and how to have the data synchronized across multiple devices?
Lucas there is technology for this, alias little new in the market and unknown. Her name is: Symmetricds Symmetricds is open source software for Both file and database Synchronization with support…
-
6
votes2
answers260
viewsA: Is there any difference between an infinite loop with for and while?
Is there any functional difference between the two? No. The only difference is the design of the function, some like to use for others while because the code is clearer and readable. Change the…
-
4
votes2
answers1727
viewsA: Is token in the URL safe?
Are there problems in passing the user token and id through the URL? For security reasons? Not. Tokens have this aim. It is worth mentioning that it is only necessary to take some security measures,…
phpanswered juniorb2ss 2,503 -
1
votes1
answer83
viewsA: Host server integration with local server
Friend, I believe that it is necessary to update little with the current technologies. If we’re gonna deal with controle de versão it is mandatory to use such tool for this purpose. What is version…
-
32
votes6
answers10518
viewsA: Difference between php <?php tags and <?=
Yes, there is. The tag <?php is the default for PHP file openings, unless enabled Short Tag, that lets you open PHP with <? (which may conflict with XML instructions) Already the tag <?=…
phpanswered juniorb2ss 2,503 -
1
votes2
answers2164
viewsA: Different session in browser tabs
Your problem may be facing cookie sharing. Let’s assume that the URL of produção your see p.x: prod.url.com and that of homologação be it homo.url.com. OK? When setting a cookie, it is set to…
-
2
votes1
answer81
viewsA: Create Mysql Database Table
Well, if as far as I understand you’re having trouble with the modeling. As far as I have identified you will work with many records, with many parents and many children, taking away the possibility…
-
1
votes1
answer110
viewsA: Problem when displaying array
You are going through many arrays to at the end assemble a query to get the values by date of the entries made in that UF, and own SQL tools for this. We have the function Between which is used for…
-
1
votes2
answers126
viewsA: Remove last table item and reset a new item above the first
Best way to create a dynamic of this is through a database control, where each change of user status would be recorded the status, which user belongs and the date of the change. An example of a bank…
-
3
votes1
answer247
viewsA: How to save data in Mysql using Prepared statments
The format coming in the POST is string. You need to convert to a date instance. $date = DateTime::createFromFormat('d/m/Y', $_POST['dataDMY'])->format('Y-m-d'); So the variable will be ready to…
-
0
votes2
answers1362
viewsA: Access denied. (code: 5) PHP
Lucas, this problem may be linked to several factors, internal or even external to the language, such as: Firewall, Network, Folder and User Permissions. Firewall The computer that is being accessed…
-
1
votes3
answers272
viewsA: is_numeric does not work with decimal separator ,
Considerations Well, first I will make some considerations before the validation logic implemented in your application, then I will focus on the resolution of your problem. You will decide which is…
phpanswered juniorb2ss 2,503 -
8
votes6
answers22962
viewsA: How to calculate percentage?
Just use rules of 3: function porcentagem_nx ( $parcial, $total ) { return ( $parcial * 100 ) / $total; } With this function will facilitate the percentage calculation, to use enough:…
-
30
votes4
answers5507
viewsA: Why are NULL values not selected?
Null is not a concrete string, it is null value. So SQL will not return value because you asked: Returns all records that contain value DIFFERENT FROM N on my table Thus SQL SERVER will return…
-
1
votes2
answers558
viewsA: What is the undescore "_" in the MYSQL LIKE?
The underscores _ is to find occurrences at certain position of the string. Let’s assume I’ll want to search every string that starts with my. LIKE 'my%' Will return me records as: mySQL, Myan,…
-
1
votes4
answers1278
viewsA: Difficulty with MSSQL and PHP on Centos 6 server
Hello, all good? Look, let’s look at it... The use of msssql_* classes like mysql_* is very old, you know? And it is no longer recommended to use them... For use of classes of bank connections we…
-
1
votes1
answer856
viewsA: Filter a query using an attribute in Laravel
Talk brother, come on. It is possible to do Eager Loading Information: http://culttt.com/2013/12/30/eager-loading-laravel-4/ That in your case it would be something more or less give: $Fornecedores…
-
2
votes1
answer132
viewsA: Auto load of multiple directories
spl_autoload_register(function($class) { if(file_exists('libs/'.$class.'.php') { require_once ('libs/'.$class.'.php'); } elseif(file_exists('models/'.$class.'.php') { require_once…
-
1
votes1
answer72
viewsA: Error running Gulp --Production Vagrant Laravel/Homestead
First step: Delete the pata node_modules recursively. Step two: sudo npm -g install npm@latest Step three: sudo npm install gulp --no-bin-link…
-
0
votes6
answers896
viewsA: Rewrite and close array of a file
Speak friend, it is possible yes! Using only a few functions this is simple. public function SetKeywords($Setkeyword, $Setvalue){ if(gettype($this->words) != 'array'){ $this->words = array();…
phpanswered juniorb2ss 2,503