Posts by Fábio Jânio • 3,407 points
226 posts
-
2
votes1
answer81
viewsQ: Optimizing Middleware Standard Behavior
I have the following middleware: class OwnerOrAdmin { public function handle($request, Closure $next) { $user = \Auth::user(); $postId = $request->route('post'); $post =…
-
1
votes1
answer31
viewsQ: Middleware for post handling
I created a middleware to check if the person who wants to manipulate a post owns this one or if it’s the super admin. Behold: public function handle($request, Closure $next) { $user =…
laravelasked Fábio Jânio 3,407 -
0
votes0
answers50
viewsQ: Laravel - how to authorize certain action?
I have a small application written with Laravel 5.3, at a certain point I perform a check to see if the logged-in user has permission to edit/change or delete a particular post: if(!$post =…
-
1
votes3
answers79
viewsQ: How to define an attribute to the parent form of a given input?
I have the following form: <form id="excluir" class="form-horizontal" role="form" method="POST"> <input type="hidden" name="_token" value="s59zI8Ehg0dw2CVnmqpfGgyyuHKJDHSF"> <input…
jqueryasked Fábio Jânio 3,407 -
0
votes1
answer310
viewsQ: How to create a link to call Resource Stroy?
I have a Blade view with the following structure: @forelse($posts as $p) <tr> <td><a href="/post/{{ $p->id }}">{{ $p->titulo }}</a></td> <td>{{…
-
2
votes2
answers98
viewsQ: How to relate two records in an elegant way?
At a certain point of my application I am creating a post and relating this to the session user: public function adicionar(CadEditPost $request) { $request->merge(['user_id' =>…
-
7
votes3
answers89
viewsQ: How to parse a string array for a multidimensional array?
I have the following array: Array ( [0] => MemTotal: 4060964 kB [1] => MemFree: 3630320 kB [2] => MemAvailable: 3789472 kB [3] => Buffers: 93040 kB [4] => SwapCached: 0 [6] =>…
phpasked Fábio Jânio 3,407 -
2
votes0
answers44
viewsQ: Is it appropriate to migrate common resources to more than one project into an independent package?
I built two packages in PHP, each of these perform very different functions, however, both implement practically the same interfaces and abstract classes. Because of this I created a third package…
-
0
votes0
answers42
viewsQ: What is the best approach to dealing with loosely coupled code?
What would be the correct way to structure the code below? For example, is it appropriate to pass an instance of Connectorwmi as a parameter and use it to execute an instruction? Or would you have a…
phpasked Fábio Jânio 3,407 -
4
votes1
answer168
viewsQ: In the specialized class should I use self or Parent to access the variables?
I have two classes, one abstract (Connector) and a specialized class (Connectorwmi) extending from Connector. My question is, considering the code below, in the specialized class I should rather…
phpasked Fábio Jânio 3,407 -
3
votes1
answer454
viewsQ: Should I use abstract class or interface?
I have a class that connects to Windows machines. I’m making it a little more generic so I can repurpose it to other systems. Soon I was able to identify four methods "generic": connect status…
-
1
votes1
answer27
viewsQ: How does Composer behave when upgrading packages?
I have the version ^1.0.0 of a package. As well as autoload prefix "\\Empresa\\Pacote": "lib/". In case I rename the directory lib/ for src/. The right thing would be to make the package available…
commiserateasked Fábio Jânio 3,407 -
2
votes3
answers137
viewsQ: How to parse the return of the __getFunctions() class Soapclient method
I consulted a Web Service using the class SoapClient of PHP and the method __getFunctions() to list the services provided by this Web Service. I got the return below: Array ( [0] =>…
phpasked Fábio Jânio 3,407 -
3
votes1
answer58
viewsQ: How to define the semantics of downloaded packages with Composer?
I created some PHP packages with the help of Composer as dependency manager and made them available in Packagist (https://packagist.org/users/fabiojaniolima/packages/). After uploading the packages…
-
0
votes1
answer25
viewsQ: How to define the required operating system in the Composer?
I built a PHP package for deployment via Composer, but this only works on Windows machines. In Composer.json it is possible to specify this restriction?
commiserateasked Fábio Jânio 3,407 -
3
votes1
answer580
viewsQ: How to make available a package created with Composer?
The json below is part of the Composer.json file of a package I created: { "name": "libspkgs/utils", "type": "library", "description": "Descrição aqui.", "keywords": ["key1", "key2"], "homepage":…
-
0
votes0
answers30
viewsQ: How does installing packages from the same vendor work on Composer?
I have a question, let’s assume that I have two libraries (different packages) that can be installed via name in the Composer.json file is respectively: Enterprise/financial Company/teams The first…
commiserateasked Fábio Jânio 3,407 -
2
votes1
answer271
viewsQ: How to upload image to Ckeditor interface?
I built a small blog with help from Laravel 5.3 framework. In the area of creating posts I’m using the Ckeditor, but I’m struggling to build an efficient upload "method/scheme". There are many…
-
3
votes1
answer51
viewsQ: How to show string to a given occurrence?
I want to display a string until occurrence X, I could only do it this way: echo substr($conteudo, 0, strpos($conteudo, 'quebra-de-linha')); In PHP is there a native resource that can do this? So I…
phpasked Fábio Jânio 3,407 -
0
votes1
answer43
viewsA: Ckeditor does not display php tags in textarea
I found a solution here: http://komlenic.com/246/encoding-entities-to-work-with-ckeditor-3/ With this, before sending the content to the Ckeditor I’m making a character substitution:…
-
0
votes1
answer43
viewsQ: Ckeditor does not display php tags in textarea
I’m using Ckeditor, everything goes well, however, I can’t make posts ('tutorials') that contain php tags. For example: <?php acho 'teste'; The tag <?php is not displayed. Is there any…
-
3
votes1
answer388
viewsQ: Would it be possible to override Laravel’s with method?
In parts of my application I am using the following redirect: return redirect('/painel/posts') ->with(['error' => 'Ocorreu um erro ao tentar adicionar o post!']); It would be possible in the…
-
2
votes2
answers92
viewsQ: When using the Laravel view helper, what kind of data is being returned?
I am doubtful when commenting on the method below: public function index() { $posts = Post::orderBy('created_at', 'desc')->paginate(10); return view('painel.post.listar', compact('posts')); } It…
-
0
votes0
answers527
viewsQ: How to change the default name of the Laravel users table columns
I am interested in changing the default name of the table columns users and password_reset of Laravel 5.3. My question is, in which locations or configuration files should I replicate this change?…
-
1
votes1
answer160
viewsQ: What is the best way to query a user’s data in Laravel?
When presenting multiple user data in a view, it is more advisable to do it in what way? Option 1 (pass data to view): $usuario = Auth::user(); return view('painel.usuarios.perfil',…
-
3
votes1
answer6521
viewsQ: Using Count() in Laravel
I have a controller who plays for my view the total number of courses registered in the portal. My doubt is due to the operation of the method count(). For example, the output of both instructions…
-
10
votes1
answer1326
viewsQ: Laravel 5.3 - Events or Observers?
I have some scenarios where I can use Observers to fire a notification, however, for me it would be indifferent to use Observer or create an Event, a Listener and then use this to fire a…
-
1
votes1
answer984
viewsQ: What is the best way to use Notifications in Laravel 5.3
I’m using the event Registered of Laravel himself (Illuminate Auth Events Registered) to fire a Listener I created to fire a welcome email. See how the Listener turned out: <?php namespace…
-
3
votes2
answers913
viewsA: Use $_POST in a Php variable
Let’s break it up in stages: Organizing: I suggest you declare the scope of the class first, only then to work on the scope outside of it. This approach leaves the code more organized. Scope/safety:…
-
1
votes1
answer118
viewsQ: Routes in Laravel
When prefixing the middleware auth, as below, I am automatically implementing also middleware web? Route::group(['prefix' => 'painel', 'middleware' => 'auth'], function() { // }…
laravelasked Fábio Jânio 3,407 -
1
votes2
answers2002
viewsQ: Laravel 5.3 - How to change a logged-in user’s password?
I’m having difficulty creating a method that allows me to make a password change form available to logged in users. I would like to use the class methods: App Http Controllers Auth…
-
0
votes1
answer34
viewsQ: Capturing URL parameter with jQuery
Current I am capturing the URL as follows: $(this).attr('href') Let’s assume the URL is: http:/test.com/login How do I capture only the end: /login
jqueryasked Fábio Jânio 3,407 -
0
votes1
answer488
viewsQ: Format date with jQuery
I am currently formatting a date field with the following mask: $("input[type='date']").mask('dD/mM/yYYY', { translation: { d: {pattern: /[0-3]/}, D: {pattern: /[0-9]/}, m: {pattern: /[0-1]/}, M:…
jqueryasked Fábio Jânio 3,407 -
3
votes3
answers15292
viewsA: VARCHAR2 field boundary size in Oracle
VARCHAR2 stores alphanumeric characters of variable size, between 1 and 4000 bytes or characters. The default size of this column is set in bytes, in your case, this may be the problem. When…
-
0
votes1
answer558
viewsA: Is it possible to define a connection pool for each user of an oracle database?
More or less, it is possible to configure in the database a session limit per user not a connection pool. For this we can create and configure profiles, thanks to this feature we can control things…
-
8
votes2
answers1783
viewsQ: Using variable with the sed command
I have the following occurrence: DirUpload=/var/log find $DirUpload | sed 's/$DirUpload//g' The question is, how to use variable along with sed?
-
2
votes1
answer72
viewsQ: Backup and deploy with shell script
I have a productive environment for which I upload html, css etc. However, every time I upload a file I must first make a backup of existing occurrences. I’m trying to build a script that does the…
shell-scriptasked Fábio Jânio 3,407 -
0
votes2
answers240
viewsQ: String parse for PHP array
I have the following string: /dev/sda1 ext4 19620732 16936800 1664184 udev devtmpfs 10240 10240 0 tmpfs tmpfs 101232 96740 4492 tmpfs tmpfs 253080 253080 0 tmpfs tmpfs 5120 5120 0 tmpfs tmpfs 253080…
-
0
votes0
answers195
viewsQ: Healthcheck in PHP
I built a PHP code that requires a web page, checks the returned HTTP code and lets you search for a string present in the html source. I used CURL for this. The code is basically this: class…
-
2
votes1
answer1287
viewsQ: Which license to choose, MIT, Apache, GPL?
I am developing an application in PHP, I want to release it so that, anyone can download the code, improve or even build derived solutions... These people will be able to sell the final product…
licenseasked Fábio Jânio 3,407 -
0
votes2
answers24
viewsA: HOW to Replace Data Between Table
That drive includes two operations. First, while selecting the Mac address to be released you perform a new Insert in table tb_macsliberados, at the end of the Insert you apply a delete to the…
phpanswered Fábio Jânio 3,407 -
0
votes3
answers108
viewsA: Instantiation of objects in php
I understood what you wanted to do, but I didn’t understand the reason or need. See if that’s it: <?php class Usuario { private $idade; private $nome; public function getNome() { return…
phpanswered Fábio Jânio 3,407 -
8
votes2
answers2428
viewsA: Can I market software that uses a GPL license?
You can sell software, packages or any other element based on a GNU/GPL license. Many people believe that the spirit of the GNU project is not to charge for distributing copies of the final product,…
licenseanswered Fábio Jânio 3,407 -
0
votes1
answer565
viewsQ: How to add image to Launchscreen.storyboard
It’s been a long time since I’ve been trying to add an image to Launchscreen.storyboard of an iOS app I’m developing. Text I can add and view while uploading the app, but I can’t see an image I…
-
1
votes1
answer151
viewsQ: How to update a Uiwebview to include and remove a Uiactivityindicatorview
I am having difficulty including and finishing the display of a Uiactivityindicatorview ("loading animation"). I have tried using webViewDidStartLoad and webViewDidFinishLoad respectively to start…
-
1
votes2
answers373
viewsQ: How to add class in jQuery to a particular element?
I have a list containing "Urls" for other pages, I’m having difficulty to pick up the URL of the current page and check if the extracted pathname is in my list of Urls, if it exists I should add the…
-
3
votes2
answers2527
viewsQ: How to import Python libraries that are in another hierarchy?
I have the following directory structure src\ conectores\ mysql.py bibliotecas auxiliares teste\ chamarMysql.py In the above structure as I can from inside the test file call Myql.py, call a class…
pythonasked Fábio Jânio 3,407 -
0
votes2
answers86
viewsA: PHP wrapper wmic
public static function parse($resultado) { ## Remove a primeira e a ultima linha $var = trim(preg_replace('/^.+\n/', '', $resultado)); # Transforma a lista retornada em…
-
1
votes2
answers86
viewsQ: PHP wrapper wmic
I’m currently using wmic on Linux to query data on a Windows machine. The web interface of the query system is written in PHP, whereas the core that makes the query is written in Python, because I…
-
3
votes1
answer374
viewsQ: Hibernate, force table name in low box
I am using Hibernate 5.2.1.Final as an implementation to handle Mysql database. The problem is that the tables are being generated with the first letter in high box, would like to force to be all in…