Return to homepage
39/44. Creating an endpoint recovery notification
This episode is for premium members only.

Take your skills to the next level with a premium membership.

Join now

Already a member? Sign in and enjoy.

Comments

Dude

v-on:click="delete" doesnt he need to pass the endpoint.id? The endpoint object should have multiple endpoints in there, so I dont see how it knows which one to delete.

  • 0
Zakaria

Make dd($endpoint) to see which one is deleted

  • 0
Alex

Each listed endpoint is within its own component, so deleting removes the current endpoint that has been passed as a prop.

  • 0
Zakaria

Hey Alex, How are you! How can I implement Datatable to display EndPoints and Checks Data ?

  • 0
Zakaria

I hope you are enjoying the course and learning a lot! If you happen to encounter the error message "SQLSTATE[42000]: Syntax error or access violation: 1101 BLOB, TEXT, GEOMETRY or JSON column 'notification_emails' can't have a default value", there is a solution for you.

To resolve this issue, you can use the following code:

use Illuminate\Database\Query\Expression;

$table->json('notification_emails')->nullable()->default(new Expression('(JSON_ARRAY())'));

  • 1
Omar

Hi Alex, the condition for the check recovery was also sending a recovery email for the first time you have a valid endpoint. I think it's due to this condition

1$check->endpoint->checks->count() >= 1

I changed to this and it's working as expected

1$check->endpoint->checks->count() > 1

So my whole conditional logic looks like this now:

1if ($check->isSuccessful() && ! $check->previous()?->isSuccessful() && $check->endpoint->checks->count() > 1) {
2 Log::info('Notify user endpoint recovery');
3 EndpointRecovered::dispatch($check);
4}
  • 1
Alex

Thanks for this, I fixed this up in a later episode already :)

  • 0
Goeki

I have a question related to episode 5:

Is there any advantage of using an Object instead of an Array? If the only goal is to limit the data which gets exposed to the frontend, we can use something like this in the backend:

return Inertia::render('Dashboard', [ 'sites' => Site::get()->map(fn($site) => [ 'id' => $site->id, 'domain' => $site->domain ]) ]);

This way there would be no need to create an api resource. Sorry for the question, i'm an Inertia.js/Vue newbie and just want to figure things out.

By the way, the method above is from Episode 16 of the Laracasts Inertia Course: https://laracasts.com/series/build-modern-laravel-apps-using-inertia-js/episodes/16

  • 0
Omar

page.props.value.endpointFrequencies didn't work for me, instead page.props.endpointFrequencies works.

I ought to share it here in case someone else faced a similar issue

  • 1
krekas

I think it's because you are using intertia v1 which wasn't released when he started this course

  • 0
Pranab

Hi Alex, I'm getting a weird ordering of videos for the section "Checking Endpoints". The video sequence for me is 20, 24, 24, 30, 21, 25, etc.

  • 0
Alex

Thanks, fixed!

  • 0
Manuel

I don't understand why you never publish code while uploading videos.

Each episode, a commit, like other creators do, like Jeffrey.

I am here not to steal your source code, but for learning purposes. Sometimes I have time to follow along, while others I while prefer to watch and see the source code.

  • 0
Alex

Thanks for the feedback, and I agree. The main reason is that I'm tweaking and adding as I go, but this could be done with a GitHub repository. I'll work on this for future courses 👍

  • 0
Rudi

Hi Alex, If you cannot provide the course resource, I think it would be better if you could post the pre-made markup in the comment section so that we can follow the video.

  • 0
Alex

Any markup used is in the resources section which you can toggle above the episode list. If you missed that, let me know and I'll work on making it clearer.

  • 0
Rudi

Yes, I missed that 😅. It turns out it is above the episode list. Thank you.

  • 0
Alex

Thanks. We're due to work on the UI for the watch page, so I'll be making that clearer :)

  • 0
Christopher

Hi Alex. It seems the ordering of the lessons in this course is a bit messed up!?

  • 0
Alex

Thanks, fixed!

  • 0
Nathan

Episode 6... is this not more complicated than it needs to be? Could you not just store the default_site_id on the user model?

Unless it's to teach people how to use Model Observers, then of course it makes sense.

  • 0
Alex

You're right, it could be simpler. Perhaps a refactor for later :)

  • 0
Arturo

why I might be getting this message? Sorry Because of its privacy settings, this video cannot be played here.

  • 0
Alex

This may be due to the country you're in. Our video provider is blocked in certain countries. A VPN would work around this.

  • 0
Phillip

M1 Mac will throw an error should you try to perform the http request without a queue. The error will be something along the lines of

1rosetta error: unexpectedly need to EmulateForward on a synchronous exception x86_rip=0x7fff203fbcdf arm_pc=0x7ffe94ad40d0 num_insts=5 inst_index=3 x86 instruction bytes: 0x56415741e5894855 0x8941505354415541
2[1] 17860 trace trap php artisan checks:perform
  • 0
Bilal

Hey everyone, I've tried to add a validation rule for updating the Endpoint Location. However, it's not working as it should be. I tried several variations with no luck.

Here are the validation rules that I've added. Maybe someone else tried to add this validation?

1public function rules(): array
2 {
3 return [
4 'location' => [
5 'required',
6 Rule::unique('endpoints')->where(fn ($query) => $query->where('site_id', $this->endpoint->site_id)),
7 ],
8 'frequency' => ['required', new Enum(EndpointFrequency::class)],
9 ];
10 }

I want to validate uniqueness of a Location within the same Site_ID and irrespective of the location Endpoint ID (This is automatically ignored by Rule Unique Database)

  • 0
Bilal

There could be a problem in the framework itself. For now, I can resolve the issue as follows.

The code below checks for a uniqueness for the endpoint's location within the same site when updating an endpoint.

1public function rules(): array
2 {
3 return [
4 'location' => [
5 'required',
6 Rule::unique('endpoints', 'location')
7 ->where('site_id', $this->endpoint->site_id)
8 ->ignore($this->endpoint->id),
9 ],
10 'frequency' => ['required', new Enum(EndpointFrequency::class)],
11 ];
12 }
  • 0
Sam

I think episode 19 is broken 😅

  • 1
Alex

You've caught a rare glimpse into an unedited Codecourse video 🙈

Thanks for letting me know Sam, all sorted!

  • 0
Lee

The deep breath at the beginning made me chuckle... Good job as usual though Alex ;)

  • 0
Viduranga

can i know what extension make -> a perfect arrow? and other useful vs code extensions you use for laravel development?

  • 0
Marcus

Try to set the font of your editor to somethinike this ...

https://github.com/tonsky/FiraCode

  • 0
Mike

For anyone that needs the Endpoint template:

1<template>
2 <tr>
3 <td class="whitespace-nowrap pl-4 sm:pl-6 px-3 text-sm font-medium text-gray-900 w-64">
4 <a href="/" class="text-indigo-600 hover:text-indigo-900">
5 Location
6 </a>
7 </td>
8 <td class="whitespace-nowrap px-3 text-sm text-gray-500 w-64">
9 Frequency
10 </td>
11 <td class="whitespace-nowrap px-3 text-sm text-gray-500 w-64">
12 Last Check
13 </td>
14 <td class="whitespace-nowrap px-3 text-sm text-gray-500 w-64">
15 Status
16 </td>
17 <td class="whitespace-nowrap px-3 text-sm text-gray-500 w-64">
18 x%
19 </td>
20 <td class="whitespace-nowrap pl-3 pr-4 text-right text-sm font-medium sm:pr-6 w-32">
21 <button class="text-indigo-600 hover:text-indigo-900">
22 Edit
23 </button>
24 </td>
25 <td class="whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6 w-16">
26 <button class="text-red-600 hover:text-red-900">
27 Delete
28 </button>
29 </td>
30 </tr>
31</template>
  • 4
harish

Hey! Alex, happy to see content on inertia, finally. Had been waiting for your take on this beautiful framework. Hope to fine-grain my understanding with your help. Cheers!

  • 0
Bilal

Hey Alex, I would use teleport to show the Modal.

Inside the SiteSelector.vue component, add the following:

1<teleport to="#modal-area" v-if="showNewSiteModal">
2 <VueFinalModal v-model="showNewSiteModal">
3 Modal content
4 </VueFinalModal>
5</teleport>

Then, open the app.blade.php and add this line right after @inertia

1<body class="font-sans antialiased">
2 @inertia
3 <div id="modal-area"></div>
4</body>
  • 2
Phillip

You can use the route helper from ziggy in the SiteSelector component and refer to the route names used in web.php i.e. for the site list you can use

1:href="route('dashboard', { id: site.id})"
  • 9
Joseph

Nice! thanks for the tip

  • 0