Posts by Wallace Maxters • 102,340 points
1,984 posts
-
4
votes1
answer1244
viewsA: Insert array into database with Laravel
Depends on your database. Arrays represent more than one datum. So I think the correct form would be, taking for example users and their various phones. $dadosUsuario = Input::only('nome', 'email',…
-
1
votes1
answer79
viewsA: Multiple Schema based on Laravel 5.1 subdomain
In the basement, in the archive config/database.php you can define more than one connection with banks Example: 'default' => 'mysql_1', 'mysql_1' => [ ... ], 'mysql_2' => [ ... ] On the…
laravel-5answered Wallace Maxters 102,340 -
2
votes1
answer264
viewsA: Change Laravel Migrations table nomenclature 5.1
In the archive config/database.php, where there is a array configuration, you must change the line that contains the following: 'migrations' => 'migrations', For what you want, how: 'migrations'…
laravel-5answered Wallace Maxters 102,340 -
1
votes2
answers122
viewsA: Doubt JS with input type file
First, you don’t use $_POST to pick up files. It is used $_FILES. Second, to upload as soon as you select the file, it can be done with jQuery. I developed a plugin to make it easier. Behold:…
-
9
votes2
answers203
viewsQ: What does the "/" bar on the border-Radius mean?
In CSS, we have the attribute border-radius. Generally the use of the following forms: border-radius:10px; border-radius:10px 20px 20px 10px; But I came across the following code one of these days…
cssasked Wallace Maxters 102,340 -
17
votes5
answers15911
viewsQ: How to make a circle in CSS without Border-Radius 100%?
I can make a circle in css with border-radius. .circle{ border-radius:100%; border:10px solid red; width:100px; height:100px; background-color:purple; } <div class="circle"></div> But I…
-
5
votes7
answers4205
viewsA: Count elements on the screen
With pure javascript you can do so: document.querySelectorAll('li').length length return the quantity of items present in your document.
-
1
votes1
answer199
viewsA: how to put text in while in php just once
This is perhaps more a CSS issue than PHP itself. .pai{ background:purple; } .pai > .filho { background:pink; float:left; width:calc(100% / 4); border:1px solid black; box-sizing:border-box;…
-
4
votes2
answers250
viewsA: How to join the query string in Laravel 4 pagination?
In the Laravel there is a method called appends, where you pass an array, which will represent the data that will go along with the attribute page at the url. Example: User::where('admin', '=',…
-
2
votes2
answers671
viewsA: What is the way to store and read settings?
As previously stated by @Maniero, it is recommended that the settings are in script PHP, since the code will only be interpreted by PHP, and you do not run the risk of having your data exposed if…
-
1
votes1
answer52
viewsA: Use classes remotely in php
Well, maybe what you want to do is something like this: Server A $chave = 'XXXYZ'; SERVER B $chave = 'XXXYZ'; SERVER B will be the server that returns the information of the requested external file.…
phpanswered Wallace Maxters 102,340 -
3
votes2
answers331
viewsQ: Is there any way to change a file from a tag?
I have a small problem in my repository: A tag file 1.0.0 and 1.1.0 need to be changed. On github I realized that there is no such option as editing when you select a tag. But is there any way to…
-
3
votes1
answer439
viewsA: How do I convert DOC and DOCX to TXT with PHP?
I managed to solve the problem. I did it this way: I open the WORD Document through the class IOFactory library PHPWord. $reader = PHPOffice\PhpWord\IOFactory::createReader('Word2007'); $phpword =…
phpanswered Wallace Maxters 102,340 -
4
votes1
answer69
viewsQ: What are the advantages of passing a Function in jQuery’s "html" function?
I discovered by accident these days ago that in jQuery it is possible to pass a callback function to the function html. Behold: $(function () { $('body').html(function () { return [1, 2, 3, 4, 5];…
jqueryasked Wallace Maxters 102,340 -
6
votes2
answers233
viewsQ: Why create the __proto__property when using Object.create?
I just asked that question How to clone an object in javascript? And another question came to me. When I create an object from another with Object.create the attribute is added to the new object…
javascriptasked Wallace Maxters 102,340 -
1
votes2
answers387
viewsA: How to clone an object in javascript?
I was able to clone through the method $.extend jQuery. Behold: a = {} b = $.extend({}, a); b.nome = 'Teste'; document.write(JSON.stringify(a), JSON.stringify(b)) <script…
-
2
votes2
answers387
viewsQ: How to clone an object in javascript?
I want to pass an object per function parameter, but I don’t want that object to be changed. For this I want to pass a clone parameter. Because in javascript, by the tests I did, the object is…
-
1
votes0
answers122
viewsQ: Is it bad practice to mix English and Portuguese in my source code?
I see that some libraries made by Brazilians the codes are always in English. That’s why when I create something, I always do everything in English. The point is, sometimes I see codes where there’s…
pattern-designasked Wallace Maxters 102,340 -
40
votes3
answers1255
viewsQ: What is SRP and how is it used?
I know what SRP means Principle of Single Liability. Each class must be responsible for such a thing. What should I do to detect that I am violating the SRP? What I must take into account to apply…
-
6
votes2
answers1408
viewsA: How and when should we use Interface to document systems in PHP?
The main advantage I see of this in PHP is the question of providing flexibility to the programmer in the case of using a library where he implements his own resource. In this case, the programmer…
-
5
votes3
answers341
viewsQ: CSS condition for when you don’t have SRC in the image
I need that when an image does not have the attribute src, css automatically recognizes this and hides that element with display:none Which selector should I use to do this? Example: <img…
-
1
votes3
answers1977
viewsA: How to attach events to dynamically created elements and pass parameters?
In jQuery it is possible to assign events to a newly created element, even if it has not yet been inserted into body. What I usually do is create this element and at the same time already assign…
-
0
votes1
answer58
viewsA: Error in facebook library. "Malformed access token"
I found out what it was. Is that Facebook uses the native PHP session internally to save two data coming from the url, which is the state and the code. But the Laravel, which is the framework I use,…
-
7
votes3
answers619
viewsA: Timestamp limit January 19, 2038
Just to complement the answer, I want to point out that with the class DateTime I didn’t have that problem. Behold: $date = new DateTime('+1000 years') echo $date->format('c'); //…
phpanswered Wallace Maxters 102,340 -
1
votes4
answers2145
viewsA: What technique do I use to keep a form field completed or selected after $_POST[]?
Just to complement the answers, in frameworks like Laravel 4 it is possible to do it as follows: On the controller return Redirect::back()->withInput(); In view: {{ Form::text('name',…
-
16
votes6
answers8730
viewsA: How to create geometric shapes using CSS?
Use transform: rotate the child elements, and perspective, in the parent element. .a{ perspective:1000px; text-align:center; } .b{ transform:rotateX(-60deg); width:100px; background:gold;…
-
7
votes1
answer79
viewsA: Monthly update for days 30 and 31 in a date range
The correct way to do this would be to use DateInterval or DatePeriod. See a small example: $start = new DateTime('2010-12-02'); $end = new DateTime('2012-05-06'); $interval =…
phpanswered Wallace Maxters 102,340 -
1
votes1
answer122
viewsA: Condition To Run __Construct Function
There’s no other way, as far as I know. If you want to verify that a user is logged in or not, you will always have to check every request made by the user. In that case, I wouldn’t use the method…
-
4
votes2
answers460
viewsA: What is Closure Object and how do I get the anonymous function return as parameter?
In PHP, anonymous functions equals the instance of the class called Closure. For example: $a = function () {}; var_dump($a instanceof Closure); // bool(true) To catch the return of a Closure you…
-
7
votes1
answer439
viewsQ: How do I convert DOC and DOCX to TXT with PHP?
I have a system where the files the client will send me are all on file DOC or DOCX. But the same wants to be possible to download this document in format TXT. Is there any simple way to convert DOC…
phpasked Wallace Maxters 102,340 -
2
votes2
answers42
viewsA: How to not serialize a particular type of element with jQuery
According to the reply of SOEN: $('#ofform').on('submit', function(e) { e.preventDefault(); var serializedReturn = $('input[name!=security]', this).serialize(); }); I would prefer it that way, using…
-
2
votes2
answers145
viewsQ: create_function can be a risk to my code?
PHP from the version 5.3 has implemented the resource called funções anônimas or Closure. Its use is this way: $sort = function ($a, $b) { return $a - $b; }; $array = [1, 3, 2]; usort($array,…
-
1
votes2
answers865
viewsQ: What is the purpose of $_REQUEST?
According to the PHP Handbook: The variable $_REQUEST is an associative array that by default contains information of $_GET, $_POST and $_COOKIE. So these variables are a kind of mixture. What is…
phpasked Wallace Maxters 102,340 -
1
votes4
answers732
viewsA: How to create a function to scroll through a dynamically created PHP page and change certain text
When it comes to variable texts mixed with static text, the best solution would be to use a view (or something similar) ? I’ll create a simple view for you to understand. Example: function…
phpanswered Wallace Maxters 102,340 -
13
votes8
answers1094
viewsA: Is it recommended to use constants for configuring a PHP project?
Of all the PHP frameworks I’ve worked with to date, none of them used constants to store database connection data (and other things, for example). I often see this use of constants in older…
-
5
votes3
answers699
viewsA: Search word with file_get_contents
Use the function strpos to find the first occurrence of the string. $content = file_get_contents( 'https://www.hostgator.com.br' ); if (strpos($content, 'equipe') !== FALSE) { echo "tem a palavra";…
-
5
votes1
answer293
viewsA: What is the correct way to pass the view data to the model?
Generally, you can do the common flow of a framework The view form is submitted, the data is processed by the controller and then passed to create a model. A basic example of this can be seen like…
-
12
votes7
answers811
viewsA: How to write variables in PHP?
In addition to the @Maniero response, it really is unnecessary to reassign names to the variable in this case. The main consideration is that the variable will have the same value. Most of the time,…
-
2
votes1
answer1123
viewsA: Data Management System Log System
What you will need to do these operations in Models is probably called Model Observers. You can see some examples on the Laravel page. http://laravel.com/docs/4.2/eloquent#model-Observers class…
-
3
votes3
answers988
viewsA: Is it possible to include more than one.php file in the path of a Require?
To assist the response of @rray, reinforcement the idea of you using a function of glob united with include/require function glob_include($glob, $flag = 0) { foreach (glob($glob, $flag) as $file) {…
-
6
votes1
answer1501
viewsQ: What makes a popup block?
I’ve noticed that some libraries, such as login with facebook, always use popups for user authentication and, almost always, this popup is not blocked. Usually when it opens with a click event there…
-
0
votes1
answer58
viewsQ: Error in facebook library. "Malformed access token"
I am trying to get the contact information of the facebook user. For this I am using the Facebook PHP SDK. I can generate the login url correctly. However, when I try to get the information I get…
-
5
votes2
answers949
viewsQ: How to find the height and width of window WITHOUT JQUERY?
I’ve been asking myself that for some time. I’ve tried somehow to figure out the size of window (browser window) but could not get it. With jQuery I already know it’s just doing: $(window).height()…
javascriptasked Wallace Maxters 102,340 -
4
votes2
answers351
viewsA: Is it possible to use $this with static methods?
From what I understand, the operation of the method ele is being a common operation of a static method. There is no real iteration with the class. So in these cases, you could also define how…
-
5
votes4
answers3932
viewsA: How to align 7 elements on the same line?
There is a simple way to do this with the function calc of css. .minhas-colunas{ width: calc(100% / 7); } To ensure that padding do not interfere in the calculation, I usually use…
-
1
votes3
answers7154
viewsA: How to hide directory paths in htaccess url?
I don’t know if this is your case, but there is also a good way to hide the list of files from your server doing so: Options -Indexes
-
4
votes6
answers1359
viewsA: How to insert an if/Else into an echo?
For the case attribute Selected I would make an expression with the function printf. Thus: printf('<select %s></select>', $resultado['status'] == 1 ? 'selected' : ''); If this were on…
phpanswered Wallace Maxters 102,340 -
16
votes2
answers2766
viewsQ: What is a string template (literal string declared with "`" grave accent) for in Javascript?
I was fiddling with the Chrome console these days and then, as my keyboard was disfigured, I accidentally typed the grave accent ` instead of single quotes ' to create a string. The interesting…
-
3
votes1
answer188
viewsQ: var_dump and print_r Not Yet Implemented
I was debugging an instance of DOMAttr with var_dump and print_r and the following error occurred: Example: print_r($domnode); Exit: Not yet implemented Instead of displaying the data from objeto,…
phpasked Wallace Maxters 102,340 -
12
votes3
answers2891
viewsA: What is the need to maintain a`name` attribute in a`HTML`tag?
Goal Generally, the name attribute serves to represent a collection of values, sent through a form, to the server. Other Utilities Submission of forms to IFRAMES Ricardo, besides serving as keys to…
htmlanswered Wallace Maxters 102,340