chiefguru

Member Since 4 Years Ago

Melbourne

Experience Points
15,400
Total
Experience

4,600 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
132
Lessons
Completed
Best Reply Awards
2
Best Reply
Awards
  • 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.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    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.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 4
15,400 XP
Apr
16
1 day ago
Activity icon

Replied to Order, Items And Products Relations

@metriakon your OrderItem function names should also be singular as well.

Apr
15
2 days ago
Activity icon

Replied to Problem Sending Email In Laravel

@tomasosho Double check your port and encryption settings with your SMTP provider. SSL usually requires a certificate file and sometimes you need to add/set extra options for it to work.

The more common setup is to use TLS on port 587. This is what we use with Amazon SES and Mailtrap.

Apr
14
3 days ago
Activity icon

Replied to FULLTEXT Indexes At Migrations

This doesn't work if you have table prefixes, I had to write

DB::statement('ALTER TABLE '.DB::getTablePrefix().'laravel_fulltext ADD FULLTEXT fulltext_title(indexed_title)');

to get the right table prefix.

Is there a better way?

Apr
12
5 days ago
Activity icon

Replied to Designing Dynamic Email Template System

Hi @orjan we use two different types of email templates stored in our database.

One set are simple HTML templates with ##placeholder## tags which we replace at the point of emailing and a second set using twig templates for our complicated administrative emails. These we render using twig then email.

We don't use the built-in Mail facade to send emails, we use SwiftMailer.

Apr
09
1 week ago
Activity icon

Replied to Controller Organization Tip Required

@mirino77 You could put the Google stuff into one or more event listeners and the at the end of the store method, trigger an event to do the external bits.

Apr
08
1 week ago
Activity icon

Replied to Download Excel File

Guys, I use this for downloading Word files. I store the originally uploaded file path in two parts path and filename as the path is different for each of my logged in users but it'll give you the basic idea.

<a href="{{$r->original_path}}{{$r->original_name}}"
                                       download="{{$r->original_name}}"
                                       class="btn btn-outline-info" title="Download"><i
                                            class="fa fa-download"></i></a>

There is no guarantee that the uploaded file isn't corrupted :-)

Activity icon

Replied to Fresh Laravel Install Throws Exception

Just tried it a freshly installed copy on my local machine (Windows 10) using artisan serve, nothing happened. Laravel v8.36.2 (PHP v7.4.3)

Tried on the same installation running under XAMPP, no una salchicha.

Mar
10
1 month ago
Activity icon

Replied to Show Discounted Products

@mehrdad70 If you only want to show a discounted amount when it's available, don't make table columns for them. Just display the total price as one column.

We simply display the full price with a strikethrough line and put the discounted price below.

Mar
01
1 month ago
Activity icon

Awarded Best Reply on Get Value From Multidimensional Array

Hey @ryan_160289, it's pretty basic data massaging, just remembering to get your keys and arrays right

foreach ($array_one as $key => $array_two) {
    foreach ( $array_two['_attachments'] as $key_2 => $array_three) {

        // assemble your data structure
       $data[] = [
            '_id' => $array_two['_id'],
            'id' => $array_three['id'],
            ...
        ];
    }
}
dump($data);
Activity icon

Replied to Get Value From Multidimensional Array

Hey @ryan_160289, it's pretty basic data massaging, just remembering to get your keys and arrays right

foreach ($array_one as $key => $array_two) {
    foreach ( $array_two['_attachments'] as $key_2 => $array_three) {

        // assemble your data structure
       $data[] = [
            '_id' => $array_two['_id'],
            'id' => $array_three['id'],
            ...
        ];
    }
}
dump($data);
Feb
25
1 month ago
Activity icon

Replied to How To Store Rate Field In Pivot Table In Laravel

@coder72

and because I'm never working with pivot records that aren't there, I have a tendency to use updateExistingPivot.

$user->items()->updateExistingPivot($item_id, ['rate' => $rate]);
Activity icon

Replied to How To Store Rate Field In Pivot Table In Laravel

@coder72

If you've named your pivot table correctly, you don't need to include it in your relationship definition.

public function items()
    {
        return $this->belongsToMany(Item::class)->withPivot('rate')->withTimestamps();
    }

You haven't mentioned it but you also need to set the reverse relationship in your Item model

public function users()
    {
        return $this->belongsToMany(User::class)->withPivot('rate')->withTimestamps();
    }

You might also want to include timestamps, but that's optional.

Feb
03
2 months ago
Activity icon

Replied to How To Make A Download Link In PHP

@felicia00 You need to include a download attribute like this:

<a href="{{$r->original_path}}{{$r->original_name}}"
           download="{{$r->original_name}}"
           class="btn btn-outline-info" title="Download"><i
           class="fa fa-download"></i></a>
Feb
02
2 months ago
Activity icon

Replied to Show Comment List In Modal

@marcolino922 when you click on the item, make an ajax call to grab the item comments and use the json reply to populate the modal before displaying it, then purge the modal body when the modal is closed.

We use this basic technique, to display calculated exam scores in a table of students without having to add them to the view.

Activity icon

Replied to Listen And Get All Query Logs In App

Try the boot() method in the AppServiceProvider class

Feb
01
2 months ago
Activity icon

Replied to Allowed Memory Size Of 1610612736 Bytes Exhausted (tried To Allocate 4096 Bytes)

Upgrading to composer v2 solved all of these out of memory issues for me.

Jan
29
2 months ago
Activity icon

Replied to Setting Up Laravel On A M1 MacBook?

Forgive my ignorance, but couldn't you do your development under MAMP, I think it runs on M1 macs and it's not particularly complicated.

Activity icon

Replied to Breeze Auth Logout Link

Don't forget to strip the {{ route('logout') }} out of the href tag and replace it with a #

Jan
19
2 months ago
Activity icon

Replied to AWS Cloudfront Causing CSRF Token Mismatch Exception

@sgrprasad have you set HEADER_X_FORWARDED_AWS_ELB in the trusted proxies config file?

Activity icon

Replied to Image Upload Not Working

@artisticre I don't trust the original filename, so I just use the upload filename.

$path = $request->file('video_file')->store('videos/temp_upload_store', 's3-blogs');

Jan
13
3 months ago
Activity icon

Replied to Laravel Deployment In HTTPS

@ynoth25 You might also need to add this:

    if (config('app.env') === 'production') {
        URL::forceScheme('https');
    }

to the boot() method of the AppServiceProvider.

We had to add it to get https assets in 5.8, don't know if it is relevant now with 8.x.

Jan
08
3 months ago
Activity icon

Replied to Update Is Not Working With Ajax Request In Laravel

@nafeeur10 not to sure what the FormData() function is doing here

var formData = new FormData(this);

replace it with

var formData = $('form#facultyDeptUpdateFrom').serialize();

and your posted request data should be correct

Jan
07
3 months ago
Activity icon

Replied to Created_at Hours Displaying Wrong

@m4rinos you could have simply created your own attribute on the model and returned the formatted date time.

public function getFullNameAttribute()
{
    return $this->firstname . ' ' . $this->lastname;
}
Jan
06
3 months ago
Activity icon

Awarded Best Reply on Having Trouble With Ajax Post

If you are using serialise() on your form data, then post, you don't need to use $request->json(). I have a data entry modal, with 3 fields, I serialise the data

var form_data = $('form.dataentry').serialize();

post it to my endpoint, expecting JSON back but not really needing it

            jQuery.ajax({
                url: url,
                method: 'post',
                data: form_data,
                success: function (json) {
                    //console.log(json);
                    if (json.status) {
                        Lobibox.notify('success', {msg: json.success});
                    } else {
                        Lobibox.notify('error', {msg: json.message, delay: false});
                    }
                },
                error: function (xhr, status, error) {
                    console.log(xhr);
                    console.log(status);
                    //Lobibox.notify('error', {msg: error, delay: false});
                }
            });
        });

and at my endpoint, I simply process it as I would any other form, ensuring that I return JSON responses

    $validator = Validator::make($request->all(), [
        'section1correct' => 'required|numeric|min:0',
        'section2correct' => 'required|numeric|min:0',
        'section3correct' => 'required|numeric|min:0',
        'bookingID' => 'required',
        'studentID' => 'required',
    ]);
    if ($validator->fails()) {
        //return redirect()->back()->withErrors($validator)->withInput();
        return response()->json(['status' => false, 'message' => $validator]);
    }

Hope that helps

Activity icon

Replied to How To Set A Local Timezone For Users

We store all of our date times in UTC and every student/staffer has a location field. We use a simple configuration to find which timezone belongs to that location and change all of our display and calculation datetimes to that timezone for that student/staffer.

Admittedly we only deal with 6 locations and 4 timezones, so a config file is fast and easy.

Activity icon

Replied to Setting A Global Path For Laravel Website

Make a config file as newbie360 suggests, but have it read the path from the .env file. That way you can have a different path on your production server to that of your development server.

Activity icon

Replied to Voyager Send Email Action

from the looks of your snippet, your route should be admin/email/order/confirmation, the route group isn't closed after the Voyager routes.

Jan
05
3 months ago
Activity icon

Replied to Prevent Random String Id To Be Same

Because Ramsey\Uuid\Uuid was already there, we just use it.

$token = Uuid::uuid4()->toString();

and get lovely complicated and unique tokens, like 8a61e3f7-2da3-4e42-bdee-8a12687ad6f4

Activity icon

Replied to Having Trouble With Ajax Post

If you are using serialise() on your form data, then post, you don't need to use $request->json(). I have a data entry modal, with 3 fields, I serialise the data

var form_data = $('form.dataentry').serialize();

post it to my endpoint, expecting JSON back but not really needing it

            jQuery.ajax({
                url: url,
                method: 'post',
                data: form_data,
                success: function (json) {
                    //console.log(json);
                    if (json.status) {
                        Lobibox.notify('success', {msg: json.success});
                    } else {
                        Lobibox.notify('error', {msg: json.message, delay: false});
                    }
                },
                error: function (xhr, status, error) {
                    console.log(xhr);
                    console.log(status);
                    //Lobibox.notify('error', {msg: error, delay: false});
                }
            });
        });

and at my endpoint, I simply process it as I would any other form, ensuring that I return JSON responses

    $validator = Validator::make($request->all(), [
        'section1correct' => 'required|numeric|min:0',
        'section2correct' => 'required|numeric|min:0',
        'section3correct' => 'required|numeric|min:0',
        'bookingID' => 'required',
        'studentID' => 'required',
    ]);
    if ($validator->fails()) {
        //return redirect()->back()->withErrors($validator)->withInput();
        return response()->json(['status' => false, 'message' => $validator]);
    }

Hope that helps

Dec
03
4 months ago
Activity icon

Replied to [Discussion] Best Approach To Handle Bundle Products/packages

We approach it slightly differently, our products table has a bunch of flags, one of which is can_be_bundled, we use that to apply a bundle discount to the product when it's added to the cart with something else.

Nov
19
4 months ago
Activity icon

Replied to Default Feature Test Fails With 404 Error

192-168-1-6:simple-site brett$ ./vendor/phpunit/phpunit/phpunit PHPUnit 9.4.2 by Sebastian Bergmann and contributors.

.F 2 / 2 (100%)

Time: 00:01.491, Memory: 20.00 MB

There was 1 failure:

  1. Tests\Feature\ExampleTest::testBasicTest Expected status code 200 but received 404. Failed asserting that 200 is identical to 404.

/Users/brett/Working/WebHome/Laravel8/simple-site/vendor/laravel/framework/src/Illuminate/Testing/TestResponse.php:186 /Users/brett/Working/WebHome/Laravel8/simple-site/tests/Feature/ExampleTest.php:19

FAILURES! Tests: 2, Assertions: 2, Failures: 1.

and if I use artisan

192-168-1-6:simple-site brett$ php artisan test

PASS Tests\Unit\ExampleTest ✓ basic test

FAIL Tests\Feature\ExampleTest ⨯ basic test

• Tests\Feature\ExampleTest > basic test Expected status code 200 but received 404. Failed asserting that 200 is identical to 404.

at tests/Feature/ExampleTest.php:19 15▕ public function testBasicTest() 16▕ { 17▕ $response = $this->get('/'); 18▕ ➜ 19▕ $response->assertStatus(200); 20▕ } 21▕ } 22▕

Tests: 1 failed, 1 passed Time: 0.47s

Nov
18
4 months ago
Activity icon

Replied to Having Trouble With Ajax Post

I do this fairly regularly with simple forms in modals, structure the data if I need to in JS, post to a route and handle it like a regular form submission. I usually only use JSON for the return responses.

Activity icon

Started a new Conversation Default Feature Test Fails With 404 Error

I have a clean L8 installation running under MAMP 6.0 on a Mac and I'm using PHPStorm as IDE.

When I try and run the test tests/Feature/ExampleTest.php from within Storm, the assertion fails with a 404 error. It also fails when run from artisan, so my Storm config isn't the issue.

My APP_URL is set correctly to run the app APP_URL=http://localhost:8888/Laravel8/simple-site/public/ in the browser. If I simplify the URL to http://localhost:8888/ the test works.

I'm tearing what little hair I have out over this, what basic, simple, in your face configuration have I overlooked.

Testing started at 10:20 am ... /Applications/MAMP/bin/php/php7.4.9/bin/php /Users/brett/Working/WebHome/Laravel8/simple-site/vendor/phpunit/phpunit/phpunit --configuration /Users/brett/Working/WebHome/Laravel8/simple-site/phpunit.xml /Users/brett/Working/WebHome/Laravel8/simple-site/tests/Feature --teamcity PHPUnit 9.4.2 by Sebastian Bergmann and contributors.

Expected status code 200 but received 404. Failed asserting that 200 is identical to 404. /Users/brett/Working/WebHome/Laravel8/simple-site/vendor/laravel/framework/src/Illuminate/Testing/TestResponse.php:186 /Users/brett/Working/WebHome/Laravel8/simple-site/tests/Feature/ExampleTest.php:19