Ricardo

Ricardo

at Self employée - Two SaaS

Member Since 5 Years Ago

Medellin - Colombia

Experience Points
145,330
Total
Experience

4,670 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
1402
Lessons
Completed
Best Reply Awards
54
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 30
145,330 XP
03 Aug
1 month ago

Ricardo commented on Choose Your Class Names Wisely

@reasondigital more than a property is a relation, a user hasMany watchLaters

24 Apr
4 months ago

Ricardo left a reply on Laravel Echo Documentation: Where Does `orderId` Come From?

@thebigk Yes, you are listening for a specific order; say you are in an order page and you are receiving updates of your order, you need to tell to Echo which order are you listen to.

22 Apr
4 months ago

Ricardo left a reply on Auth::user() In Api Route

@emfpc auth('api')->user()

10 Apr
5 months ago

Ricardo left a reply on Help With Laravel One To One Relationship

@zfdeveloper review my previous answer, I've added a where

Ricardo left a reply on Help With Laravel One To One Relationship

@zfdeveloper You need to tell to Image if it is a cover image or not, something like $table-> boolean('cover'); and:

public function cover()
{
   return $this->hasOne(Image::class)->where('cover', true);
}

public function images()
{
   return $this->hasMany(Image::class)->where('cover', false);
}
05 Apr
5 months ago

Ricardo left a reply on Sort Array -> Why Does This Work?

@baeckerman83 from vuejs docs

The prop is used to pass in an initial value; the child component wants to use it as a local data property afterwards. In this case, it’s best to define a local data property that uses the prop as its initial value:

props: ['myarr'],
data: function () {
  return {
    items: this.myarr
  }
},
methods: {
    handleSortClick: function(idx) {
        this.items = sortMultiArray(this.items, idx);
    }
}

Ricardo left a reply on Emojis 😎

❤️

04 Apr
5 months ago

Ricardo left a reply on LoadMorph A Distant Relation

Thank you @staudenmeir maybe it's time to go to sleep

Ricardo left a reply on LoadMorph A Distant Relation

@staudenmeir my bad I was dd(), now I get Method Illuminate\Support\Collection::loadMorph does not exist.

Ricardo left a reply on LoadMorph A Distant Relation

Thank you @staudenmeir. $users->load('activities')->pluck('activities') will remove all users and return a collection, the result must be:

- user
    - activity
        - parentable
        - parentable
    - activity
        - parentable
        - parentable
        - parentable
    - activity
        - parentable
- user
    - activity
        - parentable
    - activity
        - parentable
        - parentable
    - activity
        - parentable
        - parentable
        - parentable

Ricardo started a new conversation LoadMorph A Distant Relation

Using docs example:

use Illuminate\Database\Eloquent\Model;

class ActivityFeed extends Model
{
    /**
     * Get the parent of the activity feed record.
     */
    public function parentable()
    {
        return $this->morphTo();
    }
}

and then:

$activities = ActivityFeed::with('parentable')
    ->get()
    ->loadMorph('parentable', [
        Event::class => ['calendar'],
        Photo::class => ['tags'],
        Post::class => ['author'],
    ]);

Now to the question. Given a:

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    /**
     * Get the activities of a user.
     */
    public function activities()
    {
        return $this->hasMany(ActivityFeed::class);
    }
}

How to loadMorph?

Something like $users->loadMorph('activities.parentable', ...);

Thanks for the time.

01 Apr
5 months ago

Ricardo left a reply on Filter Scopes Don't Show Even Months.

jaja @snapey, my answer is correct but does not respond to the question, you are right.

31 Mar
5 months ago

Ricardo left a reply on Filter Scopes Don't Show Even Months.

In your filter:

if (isset($filters['month'])) {
    $month = Carbon::parse("first day of {$filters['month']}")->month;
    $query->whereMonth('created_at', $month);
}

The extra variable $month is only for clarity, you don't need it.

Ricardo left a reply on Store Form Data From A Client Website Into Another Database

@agandrass would you mind marking your question as answered, thank you!

Ricardo left a reply on Eager Load Vs Model->relationship

so, @dawgonking, @snapey, the first answer is correct! that one of @ricardo yuju

Ricardo left a reply on Laravel API Keys In AWS

@deepu07 Give permissions to the user running your app and remove others

Ricardo left a reply on Eager Load Vs Model->relationship

@dawgonking no matter how many comments the post has those two snippets will generate two queries.

The problem will arise when you are looping through the list of posts and then looping for each post's comments

Ricardo left a reply on Laravel API Keys In AWS

@deepu07 in your .env file

30 Mar
5 months ago

Ricardo left a reply on How To Store Json Data

@lewanay when is a 409 you should see in the response the information about it.

BTW, you can use url() helper <a href="{{ url('/students/attendance') }}" id="save-btn" ... which in your case is superflus.

Ricardo left a reply on TypeError: Undefined Is Not An Object

@hjortur17 The culprit is here, isn't it?

window.events.$on('flash', message => {
    this.flash(message);
});

You should search for the window.events definition it appears not to be found, something like window.events = new Vue();

Ricardo left a reply on Laravel Retrieve All Users Where Value Match Pivot Table

@lonerunner if in you have a roles relation on user :

$users = App\User::whereHas('roles', function($query) {
        $query->where('id', 3);
    })
    ->get();

You get the idea.

Ricardo left a reply on Eloquent Query Help

@zaster If you have Company::with('po_items') it returns a query builder only when you do ->all() you get the collection.

Either:

$company = Company::with(['po_items' => function($query) {
    $query->where('status', 0)
        ->whereHas('cost_item', function ($query) {
            $query->whereHas('job', function ($query) {
                $query->where('status', 'Production');
            });
        });
    })
    ->all();

$po_item = $company->po_items;

Ricardo left a reply on Eloquent Query Help

as @ftiersch said, just PoItem::where('status', 0)... or is $po_items a query builder?

Ricardo left a reply on Need Help Pulling Specific Data From A Polymorphic Relationship

@chrisgrim take a look to $favorites->pluck('favorited')

29 Mar
5 months ago

Ricardo left a reply on Need Help Pulling Specific Data From A Polymorphic Relationship

@chrisgrim any time!

I have successfully setup a Polymorphic relationship in Laravel. A user can favorite both events and categories. The issue I am having is using that information and pulling the events from it in my controller.

Using ->with('favorited') will eager load either an App\Event or App\Category depending of the users favorites.

Ricardo left a reply on Duplicate Fields In Migration

@jonassiewertsen you can add date_time to the table, and then run a query to update date_timefrom date just below the schema definition.

Ricardo left a reply on Need Help Pulling Specific Data From A Polymorphic Relationship

@chrisgrim What if:

$favorites = Favorite::select('favorited_id', 'favorited_type')
    ->with('favorited')
    ->get();

That way you get all favorites with the favotited which is App\Event

28 Mar
5 months ago

Ricardo left a reply on How To Pass A Js Variable Into A Vue.js Instance?

@tommy001 that's a different error. You have two issues, the nextIndex you should ddand see what happens.

Ricardo left a reply on How To Pass A Js Variable Into A Vue.js Instance?

@tommy001 oh my God, for sure, it must be $nextIndex

Ricardo left a reply on How To Pass A Js Variable Into A Vue.js Instance?

@tommy001 the "{{route('showphoto')}}/{{$photos[nextIndex]->id}}" as you may know is just a string in javascript.

In your blade template :

<script>
var url = "{{route('showphoto')}}/{{$photos[nextIndex]->id}}";
</script>

Now on your js:

var app = new Vue({
        el: '#root',
        data: {
            url: url
        }
    });
27 Mar
5 months ago

Ricardo left a reply on Store Form Data From A Client Website Into Another Database

@agandrass you should use an API endpoint from your side.

You create a user and give an API token, then in your client's form post to your site given that token as part of the form.

See API Authentication

23 Mar
5 months ago

Ricardo left a reply on Passing User Data To Be Used Within Vuejs Code Base.

@simondavies I use something as you do, no problems for the time being.

Ricardo left a reply on Deploying Existing Laravel In Aws Linux

@deepu07 there is a public/mix-manifest.json file used when you do mix('js/app.js'). That file needs to be uploaded too.

Ricardo left a reply on Best Way To Handle Users Image Upload (for Gallery)

@zfdeveloper use vue-croppa and let the user select what they want.

14 Mar
6 months ago

Ricardo left a reply on Hosting A Laravel Framework Website With AWS

@johnston907 Basically EC2 is a server, Elastic Beanstalk is a service that uses EC2 to deploy your app.

25 Feb
6 months ago

Ricardo left a reply on List Of Users Online

@thepoet444 any time. (please mark one answer as the best answer, that way your post will show as resolved)

Ricardo left a reply on List Of Users Online

@thepoet444 untested:

let app = new Vue({
    el: '#app',
    data: {
        onlineUsers: [],
        usersToRemove: [],
    },

    mounted() {
        window.Echo.join('onlineUsers')
            .here(onlineUsers => (this.onlineUsers = onlineUsers))
            .joining(user => this.join(user))
            .leaving(user => this.leaving(user));
    },

    methods() {
        join(user) {
            this.onlineUsers.push(user);
            this.usersToRemove = this.usersToRemove.filter(u => u.id !== user.id);
        },

        leaving(user) {
            setTimeout(user => {
                let userToRemove = this.usersToRemove.find(u => u.i == user.id);
                if (userToRemove) {
                    this.onlineUsers = this.onlineUsers.filter(u => u.id != userToRemove.id);
                }
            }, 1000);
        }
    }
});

Ricardo left a reply on Laravel Job Check Site If Online

@dronax in a task that will run every hour. Follow this link

24 Feb
6 months ago

Ricardo left a reply on List Of Users Online

@thepoet444 I think you should have a timer before removing the user.

Ricardo left a reply on Laravel Job Check Site If Online

@dronax I think you need a Task that should run every hour and dispatch a job for each of the posts.

Your task:

foreach(Post::all() as $post) {
    CheckIfOnline::dispatch($post);
}

in App\Jobs\CheckIfOnline:

public function handle(Post $post)
{
    if ($this->checkOnline($post->site_url) {
        $post->website_online = true;
        $post->save();
    }
}

private function checkOnline($domain) {
...
23 Feb
6 months ago

Ricardo left a reply on How Do I Fetch This Relationship

@simioluwatomi users are not related to a country.

What if:

countries
    id - integer
    name - string

users
    id - integer
    name - string
    country_id - integer

posts
    id - integer
    user_id - integer
    title - string

It means that a user belongs to a country, you now can have Post::with('user.country')

17 Feb
7 months ago

Ricardo left a reply on How To Create Filter Date Between

@kokarat use either a whereBetween or two wheres

->whereDate('created_at', '>=', $fromDate)
->whereDate('created_at', '<=', $toDate)
02 Feb
7 months ago

Ricardo left a reply on Laravel Scheduled Jobs Consuming All Server Resources

@longestdrive yes, I think you should run a daemon for php artisan queue:work

26 Jan
7 months ago

Ricardo left a reply on Free Domain Emails

@daugaard47 I do also use zoho.com