Crazylife

Crazylife

Member Since 2 Years Ago

Experience Points
9,730
Total
Experience

270 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
2
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 2
9,730 XP
Oct
25
2 weeks ago
Activity icon

Replied to How To Return All Row Until A Condition Met?

I found an issue, if there's no 1 for the type, then it cannot return all as result...it will always return 1 row as the index always 0.

Activity icon

Replied to How To Return All Row Until A Condition Met?

Ohh, thanks a lot for the help!

Activity icon

Replied to How To Return All Row Until A Condition Met?

It should be return the index 0 row for me because the type = 1;

array:3 [▼
  0 => array:17 [▼
    "id" => 25
    "type" => 1
  ]
  1 => array:17 [▼
    "id" => 24
    "type" => 0
  ]
  2 => array:17 [▼
    "id" => 26
    "type" => 1
  ]
]
Activity icon

Replied to How To Return All Row Until A Condition Met?

I tried, but $index return 0 for me. I am using ->get() and apply the method you show to me. So, the new collection will return empty.

Activity icon

Started a new Conversation How To Return All Row Until A Condition Met?

This is the sample table value

| id | type  | value    |
+----+-------+-------------+
| 1  | 0      | 10          |
+----+-------+-------------+
| 2  | 1     | 20          |
+----+-------+-------------+
| 3  | 0    | 40          |

How can i write eloquent query to get my result when it detect type = 1 then stop finding next row?

My expected result
| id | type  | value    |
+----+-------+-------------+
| 1  | 0      | 10          |
+----+-------+-------------+
| 2  | 1     | 20          |

It will get the row until type = 1 found. Anyone can help with this? Thanks

I tried to use map to return null and then filter all null but not working.

$query->map(function ($q)  use($bool) {
                    if($bool === true) {
                        return null;
                    } elseif($q->type== 1) {
            $bool = true;
                        return $q;
                    } else {
                        return $q;
                    }
                });
Jul
17
3 months ago
Activity icon

Replied to How To Get A Specific Categories With Its Sub Categories Item?

yes, id category is primary. But with this way how do i get the id_category in subcategories? As what i know

$mc = Category::with('subcategories.subcategories')->where('category_name',  $category_name)->first();

//get all subcategories
dd($mc->subcategories);
Activity icon

Replied to How To Get A Specific Categories With Its Sub Categories Item?

Let's say i have 3 level, when i choose level 1, i need to get level 2 and level 3 id_category. If I choose level 2 then i will get level 2 and level 3 id_category.

Category::with('subcategories')->where('category_name',  $category_name)->get();

This only return level 2 categories, when choose level 1.

Activity icon

Replied to How To Get A Specific Categories With Its Sub Categories Item?

I am doing like this

Category::with('subcategories')->where('category_name',  $category_name)->get();

But it returned me 1 result only. I am not getting the fruits sub categories.

Activity icon

Replied to How To Get A Specific Categories With Its Sub Categories Item?

This returned me all the main categories.

Jul
16
3 months ago
Activity icon

Started a new Conversation How To Get A Specific Categories With Its Sub Categories Item?

I have this relationship in my model

public function subcategories() {
    return $this->hasMany(self::class, 'id_parent', 'id_category');
}

Let's say i have Fruit as my main parent, sub is frozen and fresh.

When user select fruit, i want to display frozen and fresh item too.

How can i do this in easy way instead of create multiple statement to get all of the id category?

My database structure

id_category | id_parent| name | 
1           |null   | fruit
2           | 1     | frozen
3           | 1     | fresh
4           | 2     | ..
Jul
13
3 months ago
Activity icon

Replied to Generate Unique Payment Reference Number

My id order will only create after payment made. Before that, will need a reference no assign to multiple id order for different vendor to show it is under same transaction.

Activity icon

Replied to Generate Unique Payment Reference Number

Yes, can include user id. But i want to make it like in 15 INT. Id user will keep increasing will caused my reference number different in length with others. Any better approach or is fine to go with this?

Jul
12
3 months ago
Activity icon

Replied to Generate Unique Payment Reference Number

Do you mean using separate table for each user? or a table called transaction?

Activity icon

Started a new Conversation Generate Unique Payment Reference Number

How can i generate unique payment reference number for each user?

Currently i am using prefix year month then increment sequence. E.g. 190700001

I am doing it in this way

Order::orderBy('created_at', 'desc')->first();

I found this will caused duplicate reference number when 2 user clicked on the same time when doing payment.

Any solution to solve this issue? I want the reference number in same length. Thanks.

Jun
19
4 months ago
Activity icon

Started a new Conversation How To Create Scheduling Task Dynamically?

For my case, how to update status of an order after 24 hours from created at date time.

E.g. i have 2 orders being placed at 1.00pm and 3.00pm. I want the order status auto update next day 1.00pm and 3.00pm.

How to make the task execute on the time only when necessary? What kind of method being used for this circumstances?

Looking for advice and suggestions, thanks.

Jun
09
5 months ago
Activity icon

Started a new Conversation Cross Database Relationship With Eloquent

How to set up the database connection to allow cross database with eloquent method?

For example, I have table A and table B.

My table A model

 public function branch()
   
    {
        return $this->belongsTo('App\Models\tableA', 'id');
    }

I wrote a query

$query = tableA::on('second_db')->get();


// looping result in blade

@foreach($query as $q)
{{ $q->branch->name }}
@endforeach

I found that the branch doesn't has any connection with it. How can i make this work?

Relationship doesnt use connection of parent model.

May
27
5 months ago
Activity icon

Replied to How To Match Word From Beginning Until A Space In A Query To Get Result?

@SNAPEY - Let's say if i have some value like "tesco store", "product tesco", "A4 tesco paper", and so on.

If i search by "tes", no result will be returned. It must enter a full word like "tesco" to return "tesco store". I no want to return other value like "product tesco", "A4 tesco paper".

At the moment. i am using this way result will not be displayed when search by "tesco store"

$model->where(DB::raw("substr(name, 1, instr(name, ' ') - 1)", 'like' , $term)->get()`

Expected result

$term = 'tesco'; // return "tesco store"
$term = 'tesco store'; //return "tesco store"
$term = 'tes'; // return nothing
$term = 'tesco s'; // return nothing
$term = 'te'; //return nothing
Activity icon

Replied to How To Match Word From Beginning Until A Space In A Query To Get Result?

@SNAPEY - For example, my database stored multiple value such as tesco store, product tesco, A4 tesco paper, and so on.

When i entered tesco, only tesco store will be returned. I want the search from beginning of the string, so product tesco, A4 tesco paper will not be returned for my case.

Next example, when i entered "tesco s", tesco store will not be returned too, it must be fully match the word like "tesco store" only return result.

I am currently using this method

substr(name, 1, instr(name, ' ') - 1)

This will match tesco, but when entered tesco store, no result will be returned.

Activity icon

Started a new Conversation How To Match Word From Beginning Until A Space In A Query To Get Result?

How to query a record where need to match word from beginning until a space?

For example, i have entered full keyword "tesco" then in my database consist of "tesco store". I would like to return this result.

If keyword "tes" entered, i will not show any record even there's partial string match with it.

I cannot use LIKE % % for it. Any method can achieve it?

May
17
5 months ago
Activity icon

Started a new Conversation (500) Internal Server Error Ipay88 Payment Gateway Integration

I have set the backendURL to https://testing.com/backend_response

using POST method for my (backend_response) route.

BackendURL need to return with the Response Data as "200" and the Response Data as "RECEIVEOK" to acknowledge that the payment status has been received.

In my controller, i already did as below


public function test() {
// some staatus code here
  return response()->setStatusCode(200, "RECEIVEOK");
}

May i know is this they way to return the response to the ipay88?

May
16
5 months ago
Activity icon

Replied to Laravel Csrf Token Mismatch In POST Request With URL

@PHPHUPPTECHNOLOGIES - Thanks for the reply, I already figured it and working fine !

May
15
5 months ago
Activity icon

Replied to Laravel Csrf Token Mismatch In POST Request With URL

@TOKOIWESLEY - I tried to exclude using your way

protected $except = [
        'response',
    ];

But still return me token mismatch, will it affected if any prefix in front of the response? E.g. www.test.com/my/response

Activity icon

Replied to Laravel Csrf Token Mismatch In POST Request With URL

@TOKOIWESLEY - I can't use blade, because i set the url for payment gateway response.

Activity icon

Started a new Conversation Laravel Csrf Token Mismatch In POST Request With URL

I am getting token mismatch when i call to a url www.test.com/response

In my web.php

  Route::post("response", '[email protected]');

I am getting token mismatch because i didnt pass any crsf_token to it.

I am doing it without ajax call.

How to solve this issue?