Month: June 2016

Let’s review a full of example of how you might submit an AJAX request to your server, once a video has concluded. Perhaps you allow your users to mark videos as "completed" (just like you can here at Laracasts). Let’s see how to do that. First, in this lesson, we’ll prepare the Laravel backend code and then use some fairly basic JavaScript and jQuery to submit the AJAX request. In the next video, we’ll switch to using npm and Vue.

Typically testing this would be pretty difficult, but with MailThief it’s simple:

use MailThiefFacadesMailThief;
class RegistrationTest extends TestCase
{
public function test_new_users_are_sent_a_welcome_email()
{
// Block and intercept outgoing mail, important!
MailThief::hijack();
$this->post('register', [
'name' => 'John Doe',
'email' => 'john@example.com',
'password' => 'secret',
]);
// Check that an email was sent to this email address
$this->assertTrue(MailThief::hasMessageFor('john@example.com'));
// BCC addresses are included too
$this->assertTrue(MailThief::hasMessageFor('notifications@example.com'));
// Make sure the email has the correct subject
$this->assertEquals('Welcome to my app!', MailThief::lastMessage()->subject);
// Make sure the email was sent from the correct address
// (`from` can be a list, so we return it as a collection)
$this->assertEquals('noreply@example.com', MailThief::lastMessage()->from->first());
}
}

You can grab the package from Github and if you’d like to learn more about the thought process behind building MailThief check out this post and video by Adam Wathan.

Freek Van der Herten and Spatie.be recently released a new version of their popular Google Analytics package.

Since the first release of this package Google has changed the preferred way of authenticating for API usage and this new version accounts for that as well as cleaned up a lot of the code and made it only available for PHP 7.0+

The Google authentication is a pain and the readme does a great job of showing you the exact steps to take. Following along I was able to complete the setup without pulling out all my hair.

After the authentication is set working with the package is really nice. As an example, I wanted to see if I could generate a list of trending pages here on Laravel News for the past month. Here is all I needed to do:

Of course, it includes other useful methods for the most common stats you will need:

fetchVisitorsAndPageViews()

fetchTopReferrers()

fetchTopBrowsers()

performQuery() – Advanced option to perform any query you need.

If you are needing to integrate with Google Analytics check out this package. Even you are not the market for analytics but still need to use Google API bookmark it as a guide for setting up API accounts.

Next up, we’ll review how to respond to any number of video-specific events. Maybe you want to write to local storage every five seconds to record the user’s progress in the video. Or maybe you want to submit an AJAX request to your server each time a video is finished. It’s all a piece of cake!
Source: Laracasts

It was announced today that Laravel 5.3 will be officially released at this years Laracon US conference.

This means it’ll be out either July 28th or the 29th. Based on the current schedule, listed on the Laracon website, it’s looking like Taylor is currently only scheduled to talk on July 28th at 5:15 PM local Louisville time. So I’m putting my money on that being the day and time.

This morning CloudFlare has been having issues in Europe and many popular websites and services are down in that region. The Laravel site and services are using CloudFlare and you may notice an outage if you are in that area.

If you need to access to the Laravel documentation you can find the original markdown files in the Github repo.