Posts by user2958276 • 103 points
16 posts
-
-2
votes2
answers109
viewsA: How to insert a serialize into the database in a string field
I would use a column of type json, mysql and postgresql already allow for example, pass a json_encode with desired information to save in this column, and use $cast as the friend said. The advantage…
-
0
votes2
answers107
viewsA: Registering data with Laravel
If you want to keep your insertion with create, as you put in your example, you pass an array of objects, then you do the following: Instead: $user->create([ $user->first_name =…
-
0
votes2
answers265
viewsA: Foreign Key between different databases
To use two different databases in the same project: 1 - In your file . env put your variables of the new bank DB_ANOTHER_HOST=localhost DB_ANOTHER_DATABASE=banco2 DB_ANOTHER_USERNAME=root…
-
0
votes2
answers23
viewsA: Can I create a model responsible for more than one table in Laravel?
Each model, as a rule, will be a table, I recommend using Relationship: https://nova.laravel.com/docs/1.0/resources/relationships.html#relationships…
-
0
votes2
answers167
viewsA: Eloquent: Relationship (JSON) -> Hasmany and Belongsto
Yes, because whenever you call user, you call phone and whenever phone calls user, that calls phone... You can take the: protected $with = ['user']; And just use the relationship normally when you…
-
-1
votes2
answers226
viewsA: Laravel and Sqlite database
Actually the speed is not only in the jumps between resources, but in their structuring of the models as well, in the wood as we save the indexes and etc. Sqlite is very good for many things, but if…
-
0
votes4
answers274
viewsA: I’m not able to create the relationship between the tables through the migrations of Laravel
Leave to make the relation between the tables in their models, in the development, in the code, and not in the database. If the problem is because of deletion use $table->softDeletes() and not…
-
1
votes2
answers242
viewsA: How to instantiate one model inside the other in the view?
I would advise you not to use foreign keys in the bank, it is a responsibility of the front to maintain integrity, in addition to that if you plan to scale your bank horizontally it would make this…
-
1
votes2
answers52
viewsA: Random key during user creation
The previous answer is good, but if you want to create something alpha number do so: private function randomId() { $permitted_chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $hash =…
-
0
votes2
answers34
viewsA: Select does not return values correctly per month
You will not have a current balance in a past month, the balance is current. In your table, when you search for an accounting account running only this: SELECT saldo_atual WHERE MONTH(periodo) = 1…
mysqlanswered user2958276 103 -
0
votes2
answers152
viewsA: How to reset or reset the app variables?
You apparently don’t need to recover the view in your process. Call this function inside your setOnClickListener button. private boolean processa(){ //testo se é float ou não try {…
-
-1
votes2
answers155
viewsA: Error printing Styles and scripts in Blade templates?
The variables you are downloading in this view would not be loading later in the order you expect, so probably the items in your view that are loading in the wrong order. Edit the question with the…
-
0
votes1
answer509
viewsA: How to validate a token?
You do not need to validate it, if your private route is within the Passport authentication middleware it will already validate automatically for you, you do not need to keep performing these…
-
1
votes1
answer211
viewsA: How to use foreach to display various array values for the view in a table
You must first convert your objects and be an object array to collect the data the way you want it: All the $object must have the same attribute value to be used in this way and not value1, value2,…
-
0
votes3
answers1872
viewsA: Create a Request validation in Laravel with the Unique rule
Hit put the Rule in your Validator when performing the update just don’t put Unique, that the Unique only goes in create protected $rules = [ ValidatorInterface::RULE_CREATE => [ 'email' =>…
-
2
votes2
answers199
viewsA: Relation Hasmanythrough returns empty Eloquent
If you put in your sale Entity and call pass the sale id public function produtos($id) { return $this->hasMany(Produtos::class, 'id', 'produto_id')->where([ 'venda_id' => $id, ])->get();…