yu0307

yu0307

Member Since 2 Years Ago

Experience Points
3,310
Total
Experience

1,690 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
24
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 1
3,310 XP
Aug
13
3 months ago
Activity icon

Replied to Laravel Macroble Mixins With Eloquent Relations

@bobbybouwmann Thank you for taking the time and help out. It seems like the issue is when class T is "mixedIn", $this became Illuminate\Database\Query\Builder, which cannot access model resources. like, if I use $this->relations(), it will return saying morphToMany not found from Builder. So, i guess my extended question is, How can we MixIn methods into a model class.

Aug
12
3 months ago
Activity icon

Started a new Conversation Laravel Macroble Mixins With Eloquent Relations

Hi guys, Can someone help out on a unique case of utilizing Mixins? Let's assume the following setup:

mixin class file T:

class T{
    public function relations(){
        return function () {
            return $this->morphToMany('users', 'target');
}
    }

    public function myUsers(){
        return function () {
            return $this->relations->first();
        }
    }
}

Model A:

class A extends Model{
}

some Class:

class someClass{

    public function test(){
        A::mixin(new T);
        A::first()->myUsers();
    }
    
}

Question: when using A::first()->myUsers(), why is $this->relations return error saying "relations" is not defined on Builder class? I thought Model uses macroable tratis.

Thanks a lot guys

Jul
26
3 months ago
Activity icon

Replied to Dynamically Setting Config File

Thank you for your prompt and kind response.

Activity icon

Started a new Conversation Dynamically Setting Config File

Is there a better way to set the config file on a fly? currently I'm using

config(['somesetting.subset' => 'new value']);

and put it under serviceprovider's register() method.

Just wondering if there is a better/safer way. something like

app('config')->setconfig(['target'=>'values']);

thanks

Jul
23
3 months ago
Activity icon

Replied to Blade Component Not Getting Parent Template Variables

For anyone else who wants to achieve the same thing. I kinda found the workaround. Short answer is-----> use Aliasing Includes.

https://laravel.com/docs/5.8/blade#including-sub-views

Aliasing allows the same behavior of component along with the ability to share data from parent template.

Use case:

  • reason for adopting components is to maximize code re-usability and simplicity. We like to insert a block of code with just one line such as @component.
  • We want to pass in options to customize the behavior of the component, and components let us do that by calling with parameters. @component(['target'='user','tag'='now'])
  • We want to eliminate the burden of having to pass in variables that are already present in the parent template when calling component. eg: when $target is present in the parent view, we want to just do @component(['tag'='now'])
  • Declaration with Blade::component() will NOT share parent template variables.

Therefore, create your reusable template and defined them with aliasing function NOT component:

Blade::include('packagename.mycomponent', 'Ohyeah');

Tag: pass variables into components from parent template. or share variables between parent template and components.

Activity icon

Replied to Blade Component Not Getting Parent Template Variables

@snapey What makes you think i was trying to make it globally available? Please offer help instead.

Jul
22
3 months ago
Activity icon

Started a new Conversation Blade Component Not Getting Parent Template Variables

Hi all, I don't know if anyone realized, when using a blade component, We can't use parent template's variables. Please see examples below:

-------------parent.blade.php-----------

@MyComponent
Slot goes here
@endMyComponent

------------MyComponent.blade.php-----------

<div>
I'm trying to read parent variable {{$target}}
{{$slot}} this is surely load.
</div>

----------SomeController.php--------------------

function index(){
    return view('parent').with(['target'=>'Please show me']);
}

When the controller renders the view with the variable $target. It is available within parent.blade.php, but it cannot be used in MyComponent.blade.php

Can anyone help?

Note:

  • Please don't suggest using partial include.
  • Please don't suggest passing into component using variable like this:
@MyComponent(['target'=>$target])
Slot goes here
@endMyComponent 

I'm trying to keep a clean usage of the component and minimize input variables when calling the component.

Jul
12
4 months ago
Activity icon

Started a new Conversation Package Dev. Append Js/html Contents To <body>

Hi all, I was just wondering,

-leave the layout completely up to the end users to design. say in our package we have a component layout that uses certain js/css library.

-how do we append that library to the end of body tag? that way we don't have to worry about the design of the layout that uses the component.

Note: we don't know how end user is going to design their master blade layout. we just want them to use the component with one simple @component('cmp'), and the libraries are automatically appended to the end of the body tag.

Note: I tried @push() and @stack(). but this method will require end user to place @stack at their own design. creating unnecessary 2nd step in deployment of the component. In addition, this will not work for style stacks, since they would most likely be inserted in the head tag, which happens before the placement of component.

Thank you for all of yall's help!