Posts by Rafael Berro • 819 points
30 posts
-
2
votes1
answer262
viewsA: Where to process data in an MVC project
You can use a class responsible for representing your templates for any type of output, this includes html, json and xml. There is a project structure Pattern commonly used in Ruby called MVP…
-
0
votes4
answers1103
viewsA: Update with Laravel does not take model id
I make the words of @Wallace Maxters (referring a user was removed?) mine, but it seems to me that the main reason for the problem is the value you defined the "primaryKey" property within your…
-
1
votes1
answer285
viewsA: Authentication in Laravel
I’ll assume you’re using the version 5.3 Laravel. The simplest way is to assign middleware Auth in the builder of his class \App\Http\Controllers\Auth\RegisterController, thus: /** * Create a new…
laravelanswered Rafael Berro 819 -
1
votes1
answer462
viewsA: Filter results with Manytomany relationship in the Aravel
Using that way you’re firing the Where method of Collection, and not of query Builder. You could try chaining the Where method right after receiving a relationship, but this would result in a…
-
1
votes1
answer36
viewsA: Incorrect return
The sign of equal <%= serves to validate and print information, which in this case is the object you are iterating (Answer). Just try to validate the expression by changing from <%=…
ruby-on-railsanswered Rafael Berro 819 -
1
votes2
answers1153
viewsA: Laravel Relationship 5.2 Eloquent
You’re finishing with the method get(), this results in a collection of templates. Try changing from: $return = \App\Cliente::find($id)->with('atividadesComerciais')->get(); for $return =…
-
3
votes1
answer6290
viewsA: Laravel - Creating select with Form::select + Model::lists
You should initialize select with an array and not Collection, try changing from $marcas = Marca::lists('descricao', 'id'); for $marcas = Marca::lists('descricao', 'id')->toArray(); or in Laravel…
-
0
votes1
answer68
viewsA: Laravel returns Incorrect table Definition;
This is because the second parameter of "integer" columns is the $autoincrement flag and not the column size. Try changing $table->integer('celular',15)->nullable(); for…
-
0
votes2
answers581
viewsA: Create New Method in Rails
In this case you will need to define your method in a helper. Helpers are classes with auxiliary methods available in views and also in controllers (through #helpers), as shown in table 1. module…
ruby-on-railsanswered Rafael Berro 819 -
1
votes2
answers304
viewsA: Laravel search function returns Tokenmismatchexception error in Verifycsrftoken.php
Your first and most important step is to read as much of official documentation (if not the entire documentation), believe me, the documentation is and always will be your best company. Before doing…
-
3
votes3
answers10007
viewsA: A3 Digital Certificate, e-CPF, how to access information with Javascript
It is not possible with Chrome and other browsers, but there is a possibility that you can perform the scan through Firefox. Googling for a while, the most I could find were two articles and a…
-
0
votes2
answers4889
viewsA: Laravel - How to recover the values of a form and redirect using the Route class?
In summary, the error happens because you are trying to send a post to the route /action_page.php (defined in your form), where you define only the route /action_page. I will make some changes to…
-
0
votes1
answer418
viewsA: Laravel does not return Belongsto
In this case you need to explicitly specify the foreign key in the relation, thus: class Produto extends Model { public function categoria(){ return $this->belongsTo('app\ProdutoCateg',…
-
0
votes1
answer232
viewsA: Foreign Key on Ruby on Rails 5
Try modifying your controller to look like this. def create @sushi = Sushi.new(sushi_params) if @sushi.save # Sucesso. else render 'new' end end private def sushi_params…
ruby-on-railsanswered Rafael Berro 819 -
3
votes2
answers155
viewsQ: Rails performing XHR request when loading pages
I have noticed that in every page/route exchange, the Rails *make a new request Ajax to search for this new data (HTML), and thus perform the page exchange. I did several searches but the closest I…
-
2
votes2
answers460
viewsA: Using theme with Laravel
Files of this type are only accessible within the public folder. Put your files inside the public folder, for example: public/css public/images public/fonts public/js Then you can call them inside…
laravelanswered Rafael Berro 819 -
0
votes2
answers82
viewsA: Laravel does not return variable passed by with
You are using the with the wrong way, according to the documentation, try this way: $deleted = $prod->delete(); return redirect()->action('ProdutoController@lista', ['deleted' =>…
-
2
votes4
answers1058
viewsA: Get the first 2 user names
You can use a collection to ensure data security without having to check if something exists before calling it. For example: $name = 'Rafael Henrique Berro'; $arr = explode(' ', $name); $collection…
-
0
votes2
answers1094
viewsA: How to return the page with the "Chor" of the LARAVEL id?
When you use the method back(), it makes use of the class Urlgenerator, to be more specific, the method previous(): /** * Get the URL for the previous request. * * @return string */ public function…
-
4
votes2
answers2630
viewsA: See total records in Laravel
If you choose not to make another select, you can use the reduce method from Collection, for example: $total = $counts->reduce( function ($carrier, $item) { return $carrier +…
-
3
votes1
answer86
viewsA: Is there any way to get the original value of an attribute of a Model then modify it?
Laravel saves the original model attributes inside the property original. $user = User::first(); $user->name = 'Rafael'; dd( $user->getAttributes(), // contém o atributo nome novo.…
-
1
votes1
answer5249
viewsA: How to use view variables in Laravel 5
Before answering your question, I have some suggestions for your code to get better and cleaner. Use English as the base language It is super important that any statement/assignment is in English,…
-
3
votes1
answer5291
viewsA: Laravel Project Deploy by Git
You can follow the tutorial for installing and configuring the Laravel here on official documentation. Taking into account that you have php and composer in its global variable PATH, for a new…
-
1
votes2
answers1613
viewsA: Laravel, foreach and database
Taking into account that your ORM is working, I’ll show you a simple way to solve the problem, sharing data between a controller and its view works as follows: Http Controllers app…
-
1
votes1
answer289
viewsA: Field return in Laravel
I recommend that you remove the score before storing these values, it will facilitate comparisons, searches and any other operation involving this column. To solve your problem, you can use the…
-
0
votes2
answers90
viewsA: Popular select with result plus a null element
You can simply add the attribute placeholder in your html field, for example: {!! Form::select('teacher', $teachers, null, ['placeholder' => 'Escolha um professor']) !!} Or, if the option escolha…
-
3
votes1
answer1294
viewsA: Laravel, increase the default fields of User authentication, already ready in the Windows via Poser
To add extra fields to the default Laravel user, make the following changes: database/Migrations/xxxx_xx_xx_xxx_create_users_table.php Schema::create('users', function (Blueprint $table) { ...…
-
5
votes1
answer355
viewsA: Gulp tasks with command line parameters
By default Gulp does not accept parameters this way, but you can use the module yargs to work with these arguments (there are several modules for this situation). I will use a simple example but…
-
2
votes2
answers1908
viewsA: Adapting Code to Laravel , CEP Automatic Fill
As simply as possible, create a route of the type controller as follows: Http app Routes.php Route::controllers( [ 'cep' => 'CepController', ] ); So create the controller: app Http Controllers…
-
1
votes3
answers1022
viewsA: How to keep a radio input selected in a view in Laravel?
I recommend using the Laravelcollection/html to generate their formularies, problems like this can be easily solved with the technique Form Model Binding. Since this package is no longer an official…