spacedog4

spacedog4

Member Since 1 Year Ago

Umuarama - PR, Brazil

Experience Points 46,760
Experience Level 10

3,240 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 442
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

03 Jun
1 month ago

spacedog4 started a new conversation How To Use Laravel Echo And Pusher In Laravel 5.8

I'm trying to build a real-time chat app, but I'm having problem with laravel echo in vue js

This chat needs an api authentication, so in my broadcast it need to

this next code is in my main app.js file

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    logToConsole: true,
    encrypted: true,
    auth: {
        headers: {
            Authorization: `Bearer TOKEN`
        },
    },
    authEndpoint: "/api/broadcasting/auth",
})

How can I get this Beare Token (that I pass on the URL) and use it in my app.js file?

22 Apr
2 months ago

spacedog4 left a reply on GetColumnListing Return Empty Array When It Shoulnd't

@SNAPEY - Yeah, sorry for that, I should review it better before post, ends up that I discovered by my own, this is a messy project, but thank you anyway

spacedog4 left a reply on GetColumnListing Return Empty Array When It Shoulnd't

Okay I discovered it

How I use multiple databases, I have a connection where I get what database should this client connect to and connect using a class and calling the method on my provider

<?php

namespace App\Helpers;

use Illuminate\Support\Facades\DB;

class DatabaseConnection {

    public static function setConnection($env_connection)
    {
        $env_connection = strtoupper($env_connection);

        config(['database.connections.mysql' => [
            'driver'   => 'mysql',
            'host'     => env("DB_{$env_connection}_HOST"),
            'database' => env("DB_{$env_connection}_DATABASE"),
            'username' => env("DB_{$env_connection}_USERNAME"),
            'password' => env("DB_{$env_connection}_PASSWORD"),
            'strict' => false,
        ]]);

        DB::reconnect('mysql');
    }
}

I can't just DB::connect(database_name) cause I'd need to store it on a variable and call it on every connection, this way I can continue using DB::table(), Model::all() that it will get the correct connection

The problem is that is some point, the schema stopped to get the correct connection and I need now to specify it like this Schema::connection(connection_name)->getColumnListing($model->getTable())

spacedog4 left a reply on GetColumnListing Return Empty Array When It Shoulnd't

@SNAPEY - Sorry, its out of context, I store the model in the class

spacedog4 started a new conversation GetColumnListing Return Empty Array When It Shoulnd't

I need to get all column names from a table

doing

$model->getConnection()->getSchemaBuilder()->getColumnListing($this->model->getTable())

or

Schema::getColumnListing($model->getTable())

it returns me an empty array $model->getConnection() returns me the connection where I can see the table is there and with the columns

Debuging the getColumnListing method I got this sql select column_name ascolumn_namefrom information_schema.columns where table_schema = ? and table_name = ? so I used it on another database software and it returned me all columns

So why getColumnListing dont return it?

17 Apr
3 months ago

spacedog4 started a new conversation Bug On A Discussion

Hey @JeffreyWay I just found a bug

Navigating in your profile, I clicked on your latest contribution for the laracast dicussions where you answer a question, but the link takes me to the page 68 where there is no reply, i think some people may delete theirs replies and this happens

Heres the links https://laracasts.com/discuss/channels/general-discussion/where-are-you-all-from?page=68#reply-504396

And heres an screenshot

http://prntscr.com/ndbn1j

I think a good solutions that I saw in others foruns is to create the link to the first page and bringing the answer to the top

13 Apr
3 months ago

spacedog4 left a reply on Dealing With Huge Tables And Pagination

I've made some research and how my query is constantly searched by codigoempresa, codigofilial, codigopedidoproducao and status creating an index of these three columns and another for pedidoproducaoetapas improved 10x my query, now, it takes 1.3 seconds, thank you guys

ALTER TABLE `pedidoproducao` ADD INDEX `pedidoproducao_idx_codigoe_codigof_status_codigop` (`codigoempresa`,`codigofilial`,`status`,`codigopedidoproducao`);

ALTER TABLE `pedidoproducaoetapas` ADD INDEX `pedidoproducaoetapas_idx_codigoempresa_codigopedidopro` (`codigoempresa`,`codigopedidoproducao`);
12 Apr
3 months ago

spacedog4 left a reply on Dealing With Huge Tables And Pagination

I made it in a different way with google sql, but it worked, now, I made same research and I dont see what can I improve in my sql, how you can see above a posted a link to the results of the explain, and all the rows are with a key and potencial key, just two of then has too many rows, but how can I decrease it?

spacedog4 left a reply on Dealing With Huge Tables And Pagination

@SNAPEY - I searched about the errors, but I could find any similar errors, it wasnt showing when I'm logged, and was giving a simple error in log file "Array to string conversion" in debug bar, but It didn't say the line, nothing

spacedog4 left a reply on Dealing With Huge Tables And Pagination

I used explain, and that is the results http://prntscr.com/nb63ti I don't know what I can improve here

spacedog4 left a reply on Dealing With Huge Tables And Pagination

@JLRDW - I configured this in google cloud sql and worked, I'll see the results and analyze, thanks

spacedog4 left a reply on Dealing With Huge Tables And Pagination

@SNAPEY - I tried, but it crashs with my application, I'm using different databases, guards, providers, multiple primary keys

spacedog4 left a reply on Dealing With Huge Tables And Pagination

@JLRDW - Researching about google cloud sql I found don't a post and configured like this http://prntscr.com/nb610b but it keeps giving me errors

spacedog4 left a reply on Dealing With Huge Tables And Pagination

@JLRDW - I manage multiple database, it is already setted to false

class DatabaseConnection {

    public static function setConnection($env_connection)
    {
        $env_connection = strtoupper($env_connection);

        config(['database.connections.mysql' => [
            'driver'   => 'mysql',
            'host'     => env("DB_{$env_connection}_HOST"),
            'database' => env("DB_{$env_connection}_DATABASE"),
            'username' => env("DB_{$env_connection}_USERNAME"),
            'password' => env("DB_{$env_connection}_PASSWORD"),
            'strict' => false,
        ]]);

        DB::reconnect('mysql');
    }
}

my issue is running this code in sql softwares, I can't find a way to set strict in phpstorm or navicat

spacedog4 left a reply on Dealing With Huge Tables And Pagination

@JLRDW - That's a list of a production history, http://prntscr.com/nb5mnz

And its also slow in the production screen http://prntscr.com/nb5npi

I need to bring somethings in the query, like that date_add where I get the date of the production and sum with the prediction days so I can order by that sum, and others things

spacedog4 left a reply on Dealing With Huge Tables And Pagination

@SNAPEY - I tried that but the SQL that Laravel generates gives me this error in PHPStorm database manager and Navicat

1055 - Expression #10 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'maxinutri.pedidoproducaoetapas.previsao' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

spacedog4 left a reply on Dealing With Huge Tables And Pagination

@JLRDW - I'll try that, acctualy, in this particular case, I'm dealing with 16000 records, an relationships, I forgot to mension that, each record can have at least 6 realations that I'm making join so, it can be 100.000 records, even than I think it's not so much

spacedog4 left a reply on Dealing With Huge Tables And Pagination

@MARTINBEAN - i tried to use the laravel debugbar, but it bugs with my project, I have differents guards and providers, also this database wasn't design by me, it's poor, have many primary keys, some tables has 4 or 5 primary keys, so I needed to use comboships for relation

but maybe this 15 seconds its caused by this poorly database than, any advice that I could improve without rebuilding everything?

spacedog4 left a reply on Dealing With Huge Tables And Pagination

@PAPA - I don't know what would be Database plugin, but yes I use ajax calls

spacedog4 started a new conversation Dealing With Huge Tables And Pagination

I have a table with more then 16000 records, I need to show it on a list and paginate, but even with simplePagination it takes 15s to query it, is there a better way to paginate it?

Important thing is that I cant select the first 100 and page 2 the next 100 cause I have filters

20 Feb
4 months ago

spacedog4 left a reply on Factory Manual Incrementing

@ADAMPRICKETT - No, the same issue :( but thank you for trying

19 Feb
4 months ago

spacedog4 started a new conversation Factory Manual Incrementing

I need to set the primary key for my table manually, so I created a function to get the last record and return it +1 (cause my table has "multiple primary keys")

But the problem is that I can't use the multiple method from the factory cause it returns all the same key

<?php

use Faker\Generator as Faker;

$factory->define(\App\Controleexportacao::class, function (Faker $faker, $overrides) {

    $faker->locale('pt_BR');

    if (!$empresa = \App\Empresa::inRandomOrder()->first()) {
        $empresa = factory('App\Empresa')->create(array_only($overrides, \App\Empresa::getPrimaryKeyGroup()));
    }

    return [
        'codigoempresa' => $empresa->codigoempresa,
        'codigoce'      => \App\Controleexportacao::generateKey(), // Here I get the last record key + 1
        'nometabela'    => $faker->word,
        'data'          => $faker->date(),
        'hora'          => $faker->time(),
        'tipo'          => $faker->randomElement(\App\Controleexportacao::tipos()->all()),
        'exportado'     => array_random(['S', 'N']),
    ];
});

I've found this solution https://stackoverflow.com/questions/44983693/laravel-factory-manual-increment-of-column but in my case this doesn't work, cause I need to get the last record key and not setup a manual key

18 Feb
4 months ago

spacedog4 left a reply on A Simpler Way To Get All Attributes From A Model Including Timestamp

Oh guys, sorry STUPID mistake, this table doesn't have the timestap columns and a class that I created confused me, getColumnListing works

spacedog4 left a reply on A Simpler Way To Get All Attributes From A Model Including Timestamp

@SNAPEY - That could be because in my $fillable I don't have the timestamp fields?

spacedog4 started a new conversation A Simpler Way To Get All Attributes From A Model Including Timestamp

I need to get all my model's table fields so I can remap it to another name

I tryied to use both codes

\Schema::getColumnListing($model->getTable());

// or

$model->getAttributes();

Both of then don't return me the created_at and updated_at fields

I need a simpler way to do this

public function($model) 
{
    return array_merge($model->getAttributes(), $model->getDates());
}
`` `
15 Feb
5 months ago

spacedog4 left a reply on OrderBy Works, Even Though Column Does Not Exist

Try to clean all the cache in the storage folder

14 Feb
5 months ago

spacedog4 left a reply on String With A "b" Prefix On Records With Accent

@CRONIX - Yes, I created a new view just to make sure

spacedog4 left a reply on String With A "b" Prefix On Records With Accent

@S4MUEL - With the first code it's inverting, in my controller it returns "André" instead in my route it returns "André"

spacedog4 left a reply on String With A "b" Prefix On Records With Accent

@S4MUEL - @s4muel the first code solved my problem, but do you know why is this happening? cause I have more them 300 fields, I cant encode then everytime that I call

spacedog4 left a reply on Problem With Latin Words

@VILFAGO - I changed everything to utf8mb4 and nothing works

spacedog4 left a reply on Problem With Latin Words

@VILFAGO - I'm convert all to utf8_mb4 and utf8mb4_unicode_ci and say here if it works

spacedog4 left a reply on String With A "b" Prefix On Records With Accent

@S4MUEL - Ohh, almost the same example, but this wouldn't make the "b" appears also on my route file? Cause when I dump it there it doesn't show the "b"

Also I'm from Brazil, I make multiples sites with accents on database and this is the first time that this occurs, the utf8_general_ci support latin words

So what should I do? Cause this "b" is preventing me to create my json response

13 Feb
5 months ago

spacedog4 left a reply on Relationship Maximum Execution Time Of 60 Seconds Exceeded

This was an error in my code, I validade the user using the filial relationship that tries to validate again and results in a infinite loop

spacedog4 started a new conversation Attribute Returns Binary String On Controller But Not On Route

I NEED A NORMAL STRING

If I get try to get my product name with the following code in my VendaitensController it returns b"André

dd(\App\Vendasitem::where('codigovi', 112685)->first()->produto->nomeproduto);

PS: the same occurs in my VendasitemRequest, etc, I've tested in multiples files and all of them return the binary string

BUT in my routes file

web.php

the same come returns a normal string "André"

Route::get('/', function () {
    dd(App\Vendasitem::where('codigovi', 112685)->first()->produto->nomeproduto);
});

spacedog4 left a reply on String With A "b" Prefix On Records With Accent

@S4MUEL - I've updated my question, take a look if it helps, and about the unpack, it just returns me an array with one value of 64

array:1 [
  1 => "A"
]

spacedog4 started a new conversation String With A "b" Prefix On Columns With Accent

When I dump the property of my model and it has an accent it returns with this "b" prefix

dump($venda_item->produto->nomeproduto); // b"teste téste"

My database is setted to utf8 and utf8_general_ci collation

spacedog4 started a new conversation Problem With Latin Words

My database is with the following config

'charset'     => 'utf8',
'collation'   => 'utf8_general_ci',

my table too, my record has the following value at the "nomeproduto" column teste tésetand when I die and dump it on screen it shows me this `teste tï¿?

What have I made?

I already used some codes that I found

SET NAMES 'utf8';
SET character_set_connection=utf8;
SET character_set_client=utf8;
SET character_set_results=utf8;

dd(utf8_encode($produto->nomeproduto));

my file is in UTF-8 encoding

nothing works

11 Feb
5 months ago

spacedog4 started a new conversation Returns Unauthenticated But Keeps Running Request

I have an API that I can export multiple data with relations, but I just buy a new server, and in this server when I make request with a big json it reachs the route file twice and returns Unauthenticated (it should'nt cause its just one request and I don't make any redirects), with a smaller json it doesn't happens.

But even return unauthenticated I can see in my logs that the request keeps runing

http://prntscr.com/mjiru1

That is my server configs

memory_limit = 200M
max_execution_time = 600
max_input_time = 600
post_max_size = 200M
upload_max_filesize = 200M
display_errors = On
display_startup_errors = On
default_socket_timeout = 600
max_user_connections = 1000
20 Nov
7 months ago

spacedog4 left a reply on Shared Hosting Uploading Images

@SNAPEY - It worked, yaaay, but instead of ../www I used /../www, but now, every time I update a file in the public folder I should update the public folder of outside the project (~/www/public) and the other files in the normal folder (~/laravel) is it right?

spacedog4 left a reply on Shared Hosting Uploading Images

@SNAPEY - The problem is, my public_path aims to the laravel/public folder on root, and the asset generate an URL and this URL aims to www so the problem is when I hit http://engenhariamrc.com.br/upload it should be hitting laravel/public/upload but it hits www/upload

spacedog4 left a reply on Shared Hosting Uploading Images

@JLRDW - I don't store the image in the database, the user crops the image than it send the base64 in the request and I convert it to a file, sabe on a folder and store the filename in the database

spacedog4 left a reply on Shared Hosting Uploading Images

@snapey my public_path should return towww folder? it shouldn't return the laravel/public folder?

16 Nov
8 months ago

spacedog4 left a reply on Shared Hosting Uploading Images

@JLRDW - But my upload is from a base64, not a file, cause the user can crop the image before upload, and when I use asset it calls the wrong folder, it calls the folder from www instead of the laravel

14 Nov
8 months ago

spacedog4 left a reply on Shared Hosting Uploading Images

@D9705996 - It gives me an file_put_contents(www/upload/projeto/capa-c838d46888f9c95d82ee7963c3aff5685bec70143fc62.png): failed to open stream: No such file or directory I think it tries to find a www folder inside the laravel folder, and can't

spacedog4 left a reply on Shared Hosting Uploading Images

@d9705996 I allready have a bind for public path

App::bind('path.public', function () {
    return base_path() . '/public';
});

the problem is that every call is working, asset, etc, but when it ill write on public_path it writes on the other folder

spacedog4 started a new conversation Shared Hosting Uploading Images

I'm using a shared hosting to my website, so the content of public folder is on www and the project is in a folder named laravel outside of it.

The problem is, everything is working well instead of my image upload, here is where I write the file

file_put_contents(public_path() . '/upload' . $dir . $name_save, $data)

but instead of saving it on www/public it saves in laravel/public so when I try to call my image mysite.com/upload/image.png it doens't work cause it can't finde the image

What am I missing?

13 Nov
8 months ago

spacedog4 left a reply on Page Loads But In Network Gets 404

@ROBSTAR - @robstar yes, I'm trying to solve a bug, when it's finished I'll turn off, thank you for the advice

09 Nov
8 months ago

spacedog4 left a reply on Page Loads But In Network Gets 404

Oh finallyyy, the three of you were corrects, I needed to put the content of public into www and create another folder outside, THANK YOU GUYS SO MUCH for helping me, I'm going to give the best answer to the first one that solved my problem.

I love this community

08 Nov
8 months ago

spacedog4 left a reply on Page Loads But In Network Gets 404

@scottplunkett I read about it, I'm from brazil I belive you may not undestand the site, https://king.host/ I'm talking with the support, because Laravel is in the list of supported frameworks