davidifranco

davidifranco

Member Since 2 Years Ago

Experience Points
17,260
Total
Experience

2,740 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
163
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.

Level 4
17,260 XP
Dec
09
1 month ago
Activity icon

Started a new Conversation Is There A Way To Get Model Changes From Form Request?

$this->route('brand')->getChanges();

return an empty array for me.

Dec
04
1 month ago
Activity icon

Commented on Automatically Resolve Dependencies

When it comes to Automatic resolution... is there a scope that Laravel uses to find the class your requesting? When Im in a controller and forget to import a class, things blow up.. But you just resolved Collaborator without any import statement... Why does that work!?

Nov
26
1 month ago
Activity icon

Replied to Is There A Way To Get S3 File As UploadedFile Or File Object?

Hey Bobby, thank you.

I figured that would be the only way.. just feels weird saving locally, just to save it back to s3.... and then delete locally.

Going to try:

Storage::disk('private')->put($path,
       Storage::get($path)
);

Then

$file = new  UploadedFile($path, $filename);

I was hoping for something that would retrieve the s3 file and put it in a temp directory... almost like a file upload.

Nov
25
1 month ago
Activity icon

Started a new Conversation Is There A Way To Get S3 File As UploadedFile Or File Object?

I need to manipulate files already stored on my s3 bucket.

How can I get a file from 3s as either a symphony file object. or UploadedFile Instance??

Oct
18
3 months ago
Activity icon

Commented on Widget Workshop

If your okay with declaring a public property that matches the name of the data method..

in ExampleWidget.php

class TrendingArticles extends Widget
{
    public $title = 'Trending Articles';
    public $articles;

    public function articles()
    {
        return Article::take(3)->get();
    }
}

in widget.php

protected function buildViewData()
{
    $viewData = [];
    foreach ((new ReflectionClass($this))->getProperties(ReflectionProperty::IS_PUBLIC) as $property)
    {
        $viewData[$property->getName()] = 
            empty($property->getValue($this)) ? 
                call_user_func($property->getName()) : 
                $property->getValue($this);
    }
        return $viewData;
}

Would this work?

Oct
16
3 months ago
Activity icon

Replied to Stuck On VueJS + Laravel POO Form Validation

Please try

this.errors.record(error.response.data.errors));

Oct
15
3 months ago
Activity icon

Replied to Function Rules(), Store() And Update() In Laravel

https://laravel.com/docs/6.x/validation#rule-unique

On update you should exclude the id being updated from unique rule.

From the docs:

Forcing A Unique Rule To Ignore A Given ID:

Sometimes, you may wish to ignore a given ID during the unique check. For example, consider an "update profile" screen that includes the user's name, e-mail address, and location. You will probably want to verify that the e-mail address is unique. However, if the user only changes the name field and not the e-mail field, you do not want a validation error to be thrown because the user is already the owner of the e-mail address.

To instruct the validator to ignore the user's ID, we'll use the Rule class to fluently define the rule. In this example, we'll also specify the validation rules as an array instead of using the | character to delimit the rules:

use Illuminate\Validation\Rule;

Validator::make($data, [ 'email' => [ 'required', Rule::unique('users')->ignore($user->id), ], ]);

Oct
04
3 months ago
Activity icon

Replied to Pass Variable From One Middleware To The Next

That's exactly what I ended up doing.. Thank you!

 $request->request->add(['log' => $this->log]);

and

public function terminate($request, $response)
{
        unset($request['log']);
}
Oct
03
3 months ago
Activity icon

Commented on Form Handling

While we’re at it... any chance we can bring back the download button on mobile??

Activity icon

Started a new Conversation Pass Variable From One Middleware To The Next

I have middleware called "LogTraffic" that records any traffic that comes through my app.

public function handle($request, Closure $next)
{
    $this->log = TrafficLog::updateOrCreate([
           'user_id' => Auth()->id() ? Auth()->id() : null, 
           'ip_address' => Request()->ip(), 
           'uri' => $request->route()->uri,
           'referer' => $request->header('referer'),
    ]);
        return $next($request);
}

I have a second middleware called "CheckRole" that checks if a user can access the requested URL.

If the user doesnt have access rights i want to update the traffic log record with a failed attempt.

something like:

$this->log->increment('fail_count');

How can i pass $this->log from the "LogTraffic" middleware to the next middleware in the pipeline? (CheckRole)

I have tried the following in my trafficLog... but no luck...

 return $next($request, $this->log);

and in handle method of CheckRole

public function handle($request, Closure $next, TrafficLog $log)

any help would be appreciated.

Oct
02
3 months ago
Activity icon

Replied to Asserting DatabaseHas And DatabaseMissing With Accessors

solved for now:

turns out you can skip accessors using $model->getAttributes();

https://stackoverflow.com/questions/17543843/skip-model-accessor

Activity icon

Started a new Conversation Asserting DatabaseHas And DatabaseMissing With Accessors

Whats the best way to go about Database testing when model has accessors. When you create a model the accessor are part of the returned object. Then when asserting the database has that exact model, you inevitably fail.

below is an example use case:

Sku Model:

public function getFullNameAttribuite()
{
    return "{$this->first_name} {$this->last_name}";
}

Test:

$sku = Factory('App\Sku')->create();
$this->assertDatabaseHas('skus', $sku->toArray()); //FAIL.. full_name is not in database.
Aug
07
5 months ago
Activity icon

Started a new Conversation Deep Nested Relation Count

A Servers has one Provider. A Provider can have many Accounts.

Before I Delete a server I would like to check if there are any accounts associated with that servers provider.

On Server model:

public function hasActiveAccounts()
{
    return $this->whereHas('Provider.Account', function ($query) {
        $query->where('active', true);
    })->count();
}

However, this always returns true even when no related models exists. It seems that whereHas is checking for any related models.. not on the specific $server.

my relationships are set correctly.. I can't seem to figure out how to find the nested relationship count.

any help would be appreciated.

thanks

Jul
22
5 months ago
Activity icon

Started a new Conversation Dynamically Throttle Jobs Using Redis

Hi I'm working on throttling the amount of times a user can send out email in a 24 hr period (based on his service provider... ie gmail, outlook, aol.. etc.). Emails are sent as queued jobs and ive set up my throttle as follows:

$limit = ($this->account->Provider->max_daily_emails/24/60);

foreach ($this->recipients as $recipient) {
    Redis::throttle($this->account->username . '_email_limit')
            ->allow($limit)
            ->every(60)
            ->then(function () use ($recipient) {

                            config()->set('mail', array_merge(config('mail'), [
                                <<-- users email config -->>
                            ]));

                             $unsubscribe_link = URL::signedRoute('unsubscribe', ['recipient' => $recipient, 'campaign' => $this->campaign]);

                             Mail::to($recipient->email)->send(new CampaignEmail($this->campaign, $unsubscribe_link, $this->account->full_name, $recipient));

                            unset($unsubscribe_link);  

                             $this->campaign->Recipients()->updateExistingPivot($recipient->id, ['sent' => now()]);

                    }, function () {

                        return $this->release(60);

                    });
}

Assuming the provider allows 500 email to be sent per day... my throttle->allow() limit equates to .3472 emails per 60 seconds... will redis then allow 1 email every 3 minutes. I guess i still haven't figured out exactly how ''' allow(); every(); block(); and release(); ''' work. Would appreciate any insight... Thanks in advance.