Developer at Taiwan

Member Since 4 Years Ago

Experience Points

630 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
Best Reply Awards
Best Reply
  • start your 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-in-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 Created with Sketch.


    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.


    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 11
54,370 XP
3 months ago
Activity icon

Replied to When I'm Using Laravel Vue Pagination I Can Only Load First Page Of Relationship Table

you should pass the page number

  axios.get('api/settlement?page=' + pageNo).then(response => { this.settlements =; });
3 months ago
Activity icon

Commented on Refactoring For Flexibility

Probably another whoops by @JeffreyWay

4 months ago
Activity icon

Replied to Error While Trying To Run Npm Watch, Possible Incompatibility?

SassError: Incompatible units rem and px.
729 │ $nav-link-height:                   $font-size-base * $line-height-base + $nav-link-padding-y * 2 

it's says you have incompatible units calculation. Make sure the math is correctly done with right units. and use (##+##) * (##/##) kind of operations for priority

4 months ago
Activity icon

Replied to Question Mark In Raw Sql Query Cause Problem

5 months ago
Activity icon

Replied to Question Mark In Raw Sql Query Cause Problem

consider using sub queries

Activity icon

Replied to Laravel - Composer Update To 7.0 - Now 500 Error

Have you consider to look at storage/logs/ and see what it says there ?

Activity icon

Replied to Need Help Converting Complex MySQL Query

as far as i know you can't do it that way because it's requires 2 queries. You should try to use whereColumn query i think will give you what you need. You can compare columns instead of values

5 months ago
Activity icon

Started a new Conversation Need Help For A Query To Be Solved.

Hi, i am trying to figure out the right query to achieve a Total Targets, Total Sales summary table.


- A `store` has many `sales`
- A `store` has many `targets`

- A `target` belongs to a `store`
- A `sale` belongs to a `store`

#stores table

| id | name    |
| 1  | Store A |
| 2  | Store B |

#targets table

| id | store_id | apply_date | amount |
| 1  | 1        | 2020/01/01 | 100    |
| 2  | 2        | 2020/01/01 | 150    |
| 3  | 1        | 2020/02/01 | 300    |
| 5  | 2        | 2020/01/01 | 400    |
| 6  | 1        | 2020/03/01 | 250    |

#sales table

| id | store_id | sale_date  | sub_total |
| 1  | 1        | 2020/01/25 | 1000      |
| 2  | 1        | 2020/01/26 | 2300      |
| 3  | 2        | 2020/01/02 | 120       |
| 4  | 1        | 2020/02/11 | 2340      |
| 5  | 2        | 2020/03/22 | 4022      |

I have a date filter applied to the query which filters the sales sale_date by range. What i am trying to do is sum targets amount multiple by days in date range. And sum sub_total of the sales within the date range. But targets amount might differer depending on the sale_date. So if a sale made within the selected ranges, i need to add 1x of the targets amount into sum of targets amount.

So as in the example data i provided, Store A has 3 sales and Store B has 1 sale within the date range. I don't have a problem with the sum of the total_sales but i have issue with the sum of targets amount. I need to sum targets amount within the date range (month) for each store as

  • 2x 100 + 1x 200 = 500 for Store A
  • 1x 150 = 150 for Store B

My Query is something like this now, which i know it's not the way to achieve. But i give as sample what i have in my hands now.

$query =Store::query();

   DB::raw('sum(targets.amount) as total_targets'),
   DB::raw('sum(sales.sub_total) as total_sales'),
->join('sales', function ($sale) {
   $sale->on('sales.store_id', '');
->join('targets', function ($target) {
    $target->on('targets.store_id', '');
->whereBetween('sales.sale_date','2020/01/01 00:00:00','2020/02/15 23:59:59')
->groupBy('', '');

what output result i expect:

| name    | total_targets | total_sales |
| Store A | 500           | 5760        |
| Store B | 150           | 120         |

Hope it is clear enough and i am looking forward for your help. Thanks.

Activity icon

Replied to AddSelect Not Working As I Think It Should

Did. you figure out this issue?i am facing the same thing. In laracast Jeff's sample, it's can detect the column but why in our cases it's says unknown column? As in your sample DB::table('inspections') you are starting your query with this table so it's should be possible to reference the columns in addSelect.

5 months ago
Activity icon

Replied to Simple Way Of Deep WhereHas

This is a laravel nova filter i am trying to make it work for multiple cases where there might be some queries has to be done to parent first like, i have a sale which is belongs to a store. And this sale has many sale_items. To find out which sale_item is belongs to which store, i have to first do a whereHas('sale') then on that i can filter the by store. But i also use same filter on other resources which has store_id on them. So i can just do my query as $query->where('store_id',$value). I know it's a bit weird to do so and i believe there is easier way to do so, so i ask if there is easier way to do it.

6 months ago
Activity icon

Started a new Conversation Simple Way Of Deep WhereHas

I have a case where i need to query multiple level of whereHas method on the model, which i need to loop through an array to figure out the how deep it will go. As in the example:

public function apply(Request $request, $query, $value)
    return $query->whereHas('sales', function ($sale) use ($value) {
        $sale->whereHas('stores', function($store) use ($value) {

i would like to achieve this using a loop something like dynamic as:

$this->parents = ['sale','store'];

return $query->when($this->parents, function ($query, $parent) use ($value) {
    $query->whereHas($parent[0].'s', function ($parent1) use ($value) {
        $parent1->whereHas($parent[1].'s', function ($parent2) use ($value) {
            $parent2->where('id', $value);
}, function ($query) use ($value) {
    $query->where('id', $value);

any easy way to achieve this? Thank you