ederson

ederson

Member Since 4 Years Ago

Experience Points 9,405
Experience Level 2

595 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 45
Lessons
Completed
Best Reply Awards 6
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.

22 Jun
2 months ago

ederson left a reply on Redirecting To Another Route Based On Condition Of A Model Attribute

And I think it should be done in a middleware not in the controller

30 Apr
3 months ago

ederson left a reply on Crawling Dynamic Data In Laravel

You don't need a crawler. Open the product page with puppeteer get the ajax link and call it yourself

05 Apr
4 months ago

ederson left a reply on Learning Laravel And Feeling Overwhelmed

The service provider thing is not very clear to me too. I ve read everything but I still can't get it.

But other than that I've found most things make perfect sense. My code is much better organised and readable.

The videos here are great help too.

01 Apr
4 months ago

ederson left a reply on How Do I Become Good At Programming

all answers are helpful but pay attention to @jlrdw altjough it may seems not important.

When i started with laravel i kept copy-pasting to go faster and after a while i realized i couldn't remember anything. Nothing sticks to mind unless you type it yourself

28 Mar
4 months ago

ederson left a reply on Running Tests In A Job Uses Wrong .env

I know it sounds strange

As i said i use multiple APIs which are not to be 100% trusted that will always work. So i need to test every now and then that each API is working and that the return values are formatted as expected.

I can run the tests manually without a problem but i'd rather automate the process with a scheduled job and getting an email with the results

I guess could write a separate class to handle this test...

ederson started a new conversation Running Tests In A Job Uses Wrong .env

For a project i need to fetch data using 3rd party apis. The problem is that those APIs cannot be trusted in the sense that can change the output or even stop working (strange i know but that is the way it is)

So i could either make a class to handle the tests or what in my mind is better is use phpunit .

I dispatch a job and call the phpunit test with Symphony's process


        $process = new Process(['./vendor/bin/phpunit', './tests/Unit/Api1Test.php','--testdox-xml', 'test.xml']);
      
        $process->run();

The problem is that it load the wrong environment Instead of .env.testing is uses the normal .env file.

Is that the expected behavior or i am doing something wrong ?

25 Jan
6 months ago

ederson left a reply on Decide How To Extend A Model

@STEVECOVE - I actually read that article yesterday trying to figure this out :D

in a controller i have something like this


public function something(){
    $categories=Category::somescope()->get(): 

    $specialCategories=$categories->keepSpecialCategories();

    $specialCategories->each->doSomethingForSpecialCategory();
}

$categories is collection of Category objects as is $specialCategories so i don't have access to the SpecialCategory class' methods

The more i think about it the more it looks like that the second DB call is inevitable

ederson left a reply on Decide How To Extend A Model

@STEVECOVE - So far the difference is only in singular methods

i faced the opposite problem with another class and ended up using a service as you proposed

ederson left a reply on Decide How To Extend A Model

I think i didn't explain it correctly and i wasted your time

there is a flag already there. seperating which is normal and which special is not the issue

class Category {
    public function getName() 

    public function changeName() 

    public function doSomethingToASpecialsCat() 

    public function doSomethingElseToASpecialsCat() 
}

The category model will include some or maybe many functions that should be avaiable only to a SpecialCategory. To me this looks a bit ugly. I would like to seperate the logic.

Having

class SpecialCategory extends Category{ 
}

solves this problem. But in this case i need two DB calls to the same table to get the the normal categories and another to get the Special (otherwise all results will be of the same class). If don't seperate the logic i need one call but as i said looks wrong

Putting the Specialcategory logic in a Trait keeps the model cleaner ,i still need one db call but it wrong usage of Traits

ederson left a reply on Decide How To Extend A Model

The problem is not how to determine if a record is a normal category or special but how to seperate the code.

In this case i will have to keep the logic for all kind of categories in the Category model. It doesn't look like a good practice

ederson started a new conversation Decide How To Extend A Model

Hi all

I have a model called Category and another model let's say called SpecialCategory whichis just that a category with extra features.

Sometimes i need to get all Categories, sometime only SpecialCategories and sometimes the no SpecialCategories.

I having hard time determining the best way to structure this

It makes sense to have one table for both and extend Category but then i gets a bit confusing. If want all categories the SpecialCategories will appear in the resulting collection as Category so i will need a second db call

I thought about using a Trait and put the SpecialCategory logic there but it doesn't look right.

Or maybe just keep the SpecialCategory logic in the Category but that looks messy

Is there any alternative i haven't thought of ?

20 Jan
7 months ago

ederson left a reply on MYSQL TAKES UP 200+% OF MY CPU

The first thing that comes to mind (and probably you ve done this already) is caching to reduces the requests to the db

ederson left a reply on Overriding Default Str_slug - Possible?

That is how I do it. But like everything that comes with coding I am not sure it's the best way. Looks nice and clean though

ederson left a reply on Overriding Default Str_slug - Possible?

I usually handle it as you describe but I create a new helper.

I think str_slug() calls Str::slug. So even if you extend str::slug you won't be able to use the helper.

12 Jan
7 months ago

ederson left a reply on Have A Service Available In A Class

Unfortunately timeInterval needs constructor parameter. The construction of timeInterval is not complicated but i"d rather not repeat the code.

I"ve thought about creating a singleton in the service provider and then use App::make('timeInterval ') in every place i need it .

ederson started a new conversation Have A Service Available In A Class

Lets say we have a base class Chart (not a model) and Triangle , Bar, Pie that extend Line

In a controller i inject a service timeInterval which is used by the controller methods and should be passed to the Chart objects

So the controller is full of calls like Pie::create($this->timeInterval,$data);

It doesn't look good. My rule of thumb is that if i write the same thing many times there should be a better alternative

I could create a new instance of the timeInterval class but then i have to duplicate the initialization code i use in the service provider

Is there a way to avoid this and have the service availabe in the Chart class directly?

23 Dec
7 months ago

ederson left a reply on How To Store Time With Am/pm In Laravel 5.6?

If I were you I'd store it as timestamp and format it as I want through an accessor

02 Oct
10 months ago

ederson left a reply on Best Way To Get Running Totals Via Eloquent

I tried to solve the same problem a few weeks ago. Ended up doing something like cronix suggests. I didn't do any performance tests but it is very clean. I get the sums with SQL per month and then add the monthly totals in php.

I m happy with it ?

28 Sep
10 months ago

ederson left a reply on Homestead Newbe Questions..

Not a vagrant guru but this

- map: ~/Documents/projects/tests
  to: /home/vagrant/tests

Instructs homestead to copy your local Documents/projects/tests in the vm's Filesystem. This doesn't exist in your actuall file system and that is why you cannot locate the path home/vagrant/tests.

So you can either connect through ssh and access the files in home/vagrant/tests or using explorer go to Documents/projects/tests

20 Sep
11 months ago

ederson left a reply on Separating API Controllers And Web Controllers

Because your controller extends App\Http\Controllers\Controller

ederson left a reply on Form Request: The Request User In Null

stupid stupid stupid !!!!!!!!!!!!!!!!!!!!!

i use the api route file and i for some strange reason i assumed that auth:api is applied by default !

thanks for the help!

ederson left a reply on Form Request: The Request User In Null

thanks tykus but i ve tried it already

request()->user() returns null

I've checked that the $user passed in actingAs is as actual user

ederson left a reply on Form Request: The Request User In Null

Sorry i should have added it in the first place It is a very simple test

$this->call('POST', 'api/goup', ['name' => 'Name','team'=>'team_id']);

$this->assertEquals(false, $fails);

then in the form request i extend the validator and access request()->user()

without the custom rule it works

ederson started a new conversation Form Request: The Request User In Null

The task is to test form requests. In the general case it works fine.

There is a problem with one request where a custom validation rule is based on the user who made the request

In this case request()->user() is always null So far i tried 1)$this->be($user); 2)$this->actingAs($user); 3)manually login in a user

all failed.

any ideas on what i am doing wrong ?

15 Sep
11 months ago

ederson left a reply on "normal" Php Project With Laragon Possible?

Laragon has actuall nothing to do with laravel. Laragon is just an all in one package like xampp which makes setting up a server really easy.

After that you arrle free to use the server as you like

07 Sep
11 months ago

ederson left a reply on How To Push The Laravel Project To Server Using PuTTy In Window System?

Just follow the instructions and set the correct paths and permissions

it is not complicated

https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa

05 Sep
11 months ago

ederson left a reply on Why Laravel Dropped Elixir? Why Forcing Vue.js? What Is It That You Are Trying To Fix?

I don't get the point.... I have no idea about Vue, I dont use view I couldn't care less about view...

I just develop my ideas using whatever part of laravel I need. Nobody forces me to use Vue or passport or whatever.

Even if there is some kind of financial connection to Vue then good for Taylor. He is not taking my money...

15 Aug
1 year ago

ederson left a reply on Is Laracast Becoming Unreliable

I have a couple of a answered questions but asking from volunteers to work like payed support is irrational.

I think we take for granted things we shouldn't....

10 Aug
1 year ago

ederson left a reply on Custom Model Events And FireModelEvent

Thanks for the reply

I am talking about custom model events which are defined in & observables and cannot be automatically triggered.

But I think you solved the problem... Although I went through the source code of fireModelEvent I see that the function is protected.

Thanks ?

09 Aug
1 year ago

ederson started a new conversation Custom Model Events And FireModelEvent

There must be something embarrassing i am missing here

I have set up a few custom model events and an observer.

When i dispatch one of the event like this

    $this->fireModelEvent('someEvent"):

everything works perfectly

when i try to use the events in a controller though it is not workin

$m=Model::find(1);
$m->fireModelEvent('someEvent");

Call to undefined method Illuminate\Database\Query\Builder::fireModelEvent()

it is not making any sense to me so any help to understand what i am doing wrong will be highly appreciated

01 Jul
1 year ago

ederson left a reply on How Only Allow Authenticated User To Do API Request?

You have to create the token yourself

20 Jun
1 year ago

ederson left a reply on Laravel Echo Not Listening

I m in on the phone so I am maybe missing something but it looks like you are broacasting an event but you are listening a private channel

ederson left a reply on Unable To See Broadcast Notification?

Check if he notification is sent.

19 Jun
1 year ago

ederson left a reply on Laravel Echo Not Listening

localStorage.debug = '*';

Type this in console. Helped me a lot finding problems with Socket and echo

ederson left a reply on Unable To See Broadcast Notification?

I had the same issue. I kept trying things and suddenly it worked. I think restarting the queue helped.

Are you sure you are subscribed to the private channel?

Try localStorage.debug = '*'; It helps a lot debugging socket problems

Edit I think it is echo.private() since you are listening to private channel

16 Jun
1 year ago

ederson left a reply on Trying To Understand The Mentality

What topvillas said... We all were there... I still am.

Having said that I hate it when someone treats the forum as a free coding service where people will complete any task requested.

12 Jun
1 year ago

ederson left a reply on Is There Any Solutions To Delay Between Each Events ?

Sorry , I wan't clear... Typing on the phone is a "§%$§"$%

Instead of one job to send 100 emails , create 20 'subjobs' for emails 5 and delay each subjob

I think this way we override the server's limit but i am not sure if it is proper way of handling such a problem

ederson left a reply on Is There Any Solutions To Delay Between Each Events ?

what about despatch($sendJob)->delay() ?

11 Jun
1 year ago

ederson left a reply on Event/Listener Vs Job Vs Inline?

I've been struggling with questions like this too...

I think that event/listener would be overengineering unless you need to do more than just subscribing to the newsletter. If it is just that then I would just use the controller.

I doubt there are significant performance advantages with any method. What makes the code more readable and easier to maintain.

05 Jun
1 year ago

ederson left a reply on Web Scraping With Laravel: Goutte Or Guzzle?

You don't necessarily need guzzle to open the Web page. Guzzle makes http requests like the one you need to open the Web page. Goutte could also open a Web page with a different approach which may fail. After opening the page guzzle is useless where goutte allows you to go through the Dom structure

30 May
1 year ago

ederson left a reply on Learning Laravel

Do you have subscription. Free users can't download videos.

Looks like you want everything served on a plate... Thyrosis has a point

17 May
1 year ago

ederson left a reply on Windows 10 Laravel Dev Environment

Homestead can be a pain in the a$$ to make it work. Laragon for example in 10mins is ready to go

But running a win webserver means that you may not be able to use certain features. For example Horizon won't work

08 Apr
1 year ago

ederson left a reply on How To Make A Api Call To Third Party Within Laravel Controller?

sorry i am using the phone and i cannot format this correctly

get GuzzleHttp\Client

then in your controller

$apiCall=new Client; $response=$apiCall->get($url);

ederson left a reply on How To Get Data With Third Party API ? Which Api Was Created By Other Company ?

Are you asking in laracasts.com how to watch a laracasts.com video without subscription !??!

there is no other way to watch the video.

23 Mar
1 year ago

ederson left a reply on Laravel Open View Using Ajax

I do it this way too but i'd like to learn the proper way ....

Where do I store the html code to format the data? Keeping html code in the js file doesn't look right to me.

22 Mar
1 year ago

ederson left a reply on [Macbook] Is The Macbook Pro 13" Good For Web Development

I think you won't have a problem just some learning time to get used to iOS. My only "objection" is about the screen size ... Maybe because of the way I work but I prefer to have my editor , prompt and the browser open and visible on the screen , on a 13" I ve found this to be inconvenient

16 Mar
1 year ago

ederson left a reply on Installing Homestead Issues On Windows

I wouldn't call nightmarish procedure the homestead installation on windows and I can assure you I am not an internt guru .....

08 Jan
1 year ago

ederson left a reply on Vagrant\Homestead - Setting Up Multiple Php Versions

Thanks cronix..

I realised this a bit after posting here .... I knew a was missing something obvious

ederson left a reply on Vagrant\Homestead - Setting Up Multiple Php Versions

sorry to hijack but i have the same problem and it is driving me nuts!

i need to use php 7.1 instead of 7.2

so i destroy the vm declare the php version for the project : php: "7.1" git fetch


remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/laravel/homestead
   1be508a..241c926  master     -> origin/master

git checkout v7.0.1

HEAD is now at 0d0082e... ? ? Tagging v7.0.1 (#750)
M       composer.lock
M       resources/Homestead.yaml

and the vagrant up....

php -v keeps saying 7.2 !!!

i am obviously doing something wrong here but i have absolutely no idea what......