DennisEilander

DennisEilander

Member Since 1 Year Ago

Zwolle

Experience Points
23,380
Total
Experience

1,620 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
173
Lessons
Completed
Best Reply Awards
7
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.

Level 5
23,380 XP
Jul
29
3 months ago
Activity icon

Awarded Best Reply on 'Detatching' The Migrations And Seeders

@dylandd you want to separate the migrations and seeders, so you can share them between the website and the app?

If so, I don't think it does really make sense. Here is why.

When changing/adding a migration to your Laravel website, you should add it to your Lumen project too, so these are 2 actions. That's why you want to separate it in a single project.

Now when you have separated the migrations and seeders, you update the migrations in your single package (1 action), you need to update this package in both Laravel and Lumen projects (+2 actions) and then publish the new migrations (+2 actions) and run the seeders.

So instead of both migrations/seeders in both projects which takes you 2 actions in total, you separate them which will take you 5 actions. So I don't think separating the migrations into a single project will speed up your work and actions.

I think the best way is to keep the migrations and seeders in both projects, so you have full control over those files. If in the future the app will change some data, you can just update the migrations for the app, and your Laravel website keeps untouched.

The best way I prefer is building a global API for your website and your app. Your Laravel website will contain the public API which is used by the website itself, and the Lumen app can make use of the same api, to retrieve all needed data. Now you don't need to create the same database for the Lumen app but use the Laravel API instead.

Jul
09
3 months ago
Activity icon

Awarded Best Reply on How To Check If A URL Is An Article Or Just A Web Page?

Hi @jeroenvanrensen,

Most (modern) websites make use of the OpenGraph protocol (ogp.me). If so, you can use a webscraper to check if the meta data of that page contains a og:type property: <meta property="og:type" content="article">.

Based on this meta tag, you can determine if the page is an article, or what kind of type the object is.

However, this only works for websites which are using the OpenGraph protocol.

Maybe you need to add multiple checks to determine if the page is an article.

I have no experiences with web scrapers, but I think you can use this package for that: https://github.com/dweidner/laravel-goutte

Activity icon

Replied to Can I Get All Sessions Of A Given User With Facade\Session ?

Hi @devondahon,

I think you can use this: $data = $request->session()->all(); like in the docs: https://laravel.com/docs/7.x/session#retrieving-data

Activity icon

Replied to How To Check If A URL Is An Article Or Just A Web Page?

Hi @jeroenvanrensen,

Most (modern) websites make use of the OpenGraph protocol (ogp.me). If so, you can use a webscraper to check if the meta data of that page contains a og:type property: <meta property="og:type" content="article">.

Based on this meta tag, you can determine if the page is an article, or what kind of type the object is.

However, this only works for websites which are using the OpenGraph protocol.

Maybe you need to add multiple checks to determine if the page is an article.

I have no experiences with web scrapers, but I think you can use this package for that: https://github.com/dweidner/laravel-goutte

May
18
5 months ago
Activity icon

Replied to Output Month Name In Blade

@nickywan123

Carbon\Carbon::parse(now())->format('F Y') // May 2020
now()->format('F Y') // May 2020
May
15
5 months ago
Activity icon

Replied to Add 1,5 Hour (string) To Carbon Object

@michaloravec wow I don't know where my brain was at that moment, but yeah that's clever.

I will use that, thanks 👍

Activity icon

Started a new Conversation Add 1,5 Hour (string) To Carbon Object

Hi all,

Is it possible to do something like the example below?

$eventDate = Carbon::addDays(5); // just a Carbon date in the future
$duration = "1.5 uur"; // 1 hour 30 minutes
$duration = Carbon::parseFromLocale($duration, 'nl_NL'); // returns a carbon object with the correct time, but with the date of today


// TODO
$eventDate->addHours($duration);

I know the way the duration is saved makes it a lot harder to calculate this timestamp. So is there a way to add the duration string to the carbon object, if not, what is the suggestion to save this duration and how to convert it so it is readable by the user and it is saved correctly to de database.

===================================

(Extra information)

I have an event management tool where you simply can make a reservation to a party/event.

The event Model contains a duration field which contains a string with the duration of the event: 1 hour or 2.5 hour ( 2 hours 30 minutes). The user which fills in the duration has a dropdown select with these human readable times. The value is exact the same as the label.

Now when someone made a reservation for that event, they set the date and time (Carbon) when they want the event to be happen. It is a full Carbon date with time object.

Now I need to know that date and add the duration to it, so I know when the event will end.

May
14
5 months ago
Activity icon

Replied to Publish Service Provider

@terreporter can you show me your composer.json file, and also what command do you use when publishing the serviceprovider?

Activity icon

Replied to Problem With Request Inserting Null Values In Database

@dr24 can you show me the line of code you are referring to? I don't understand how the name input become null when you uncheck a checkbox. Do you modify it using javascript or something?

So, showing a snippet of the checkboxes and the name input would be helpful.

Activity icon

Awarded Best Reply on I Am New In Laravel And The Problem Arose After Work MIGRATE

@bscoder The problem is probably that you used strng instead of string as method type in your database/migrations/2020_05_14_132638_product_create.php file on line 21

Activity icon

Replied to How To Get Dates A Month From Now

@sarahs74 note that I get the month of the Carbon instance and then using the whereMonth instead of the where. This will match the month in the dob column only. So it ignores the year and day

Activity icon

Replied to How To Get Dates A Month From Now

@sarahs74 you can use the addMonth() method like this:

$month = Carbon::now()->addMonth(1)->month
$data = DB::table('users')->whereMonth('dob', '=', $month)->get();
Activity icon

Replied to Validation On Two Columns

@mostafalaravel checkout this Stackoverflow answer: https://stackoverflow.com/a/50350824/6385459

Maybe this will help you out.

Activity icon

Replied to I Am New In Laravel And The Problem Arose After Work MIGRATE

@bscoder The problem is probably that you used strng instead of string as method type in your database/migrations/2020_05_14_132638_product_create.php file on line 21

May
11
5 months ago
Activity icon

Replied to Unit Test Shows Response Body In Console

@tykus I found it, not sure why this way of redirecting is used, but this causes the problem.

// This will output the response body
return Redirect::to(config('app.redirect_url'), 302)->send();
// This is working as expected without any output
return redirect()->away(config('app.redirect_url'));

Thanks for your suggestions and quick response

Activity icon

Replied to Unit Test Shows Response Body In Console

@tykus thanks for your reply.

I tried to test again with the dump-server enabled, but no result. It prints nothing. I did a global search for dd() or dump() but nothing found..

Activity icon

Started a new Conversation Unit Test Shows Response Body In Console

Hi,

I'm trying to write a test to check if a non-existing urlKey is redirecting to the global redirect url. But when I run the phpunit in my console, the output contains the redirect body of the $response

For example:

mywebsite.com/non-existing-url must redirect to a global domain, which is set in the config file

This is my test:

/** @test */
public function it_will_redirect_to_global_redirect_url()
{
    $urlKey = 'non-existing-url';

    $response = $this->get(route('website', $urlKey));
    $response->assertRedirect(config('app.redirect_url'));
}

And this is my output

$ phpunit
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

.<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="0;url='https://www.redirected-domain.com/'" />

        <title>Redirecting to https://www.redirected-domain.com/</title>
    </head>
    <body>
        Redirecting to <a href="https://www.redirected-domain.com/">https://www.redirected-domain.com/</a>.
    </body>
</html>.                                                                  2 / 2 (100%)

Time: 619 ms, Memory: 26.00 MB

OK (2 tests, 3 assertions)

Is there anything wrong in the test, or is it something else I have to set? Despite the tests are passing, it is very annoying seeing this in the console.

May
10
5 months ago
Activity icon

Replied to Implementing A Simple Animated Checkbox On Click (like Laracasts)?

For people entering this (open) thread:

Here is a working example of the animated radio button, used in Laracasts.

https://codepen.io/DennisCodePens/pen/bGVMQbY

Activity icon

Replied to "554 5.5.1 Error: No Valid Recipients" On Password Reset

@loomix if you are sure that your credentials are correct and you setup your configuration the right way, you should either give us (the community) the right information or update your code snippets, because there were several issues in your code snippets which gave us the idea this was the error/problem.

Otherwise it is hard to help you solving the problem.

Activity icon

Awarded Best Reply on Extra Slash In The Route

@ara if your riot.txt file is in the public folder, you can access it without creating a route for it. Just like you will access your robots.txt file in the public folder.

If your want a route that downloads/shows a file from your storage folder, you should create a route like /file and return File::get(storage_path('path/riot.txt'));

Activity icon

Replied to Notification::send With Non-existing User Model

yes this way it will work, but I didn't like to add thos properties in the notification itself. And maybe the logic needs to be refactored as well.

I prefer the solution to pass properties to the notification rather than creating temporary models.

I think I got my answer, thanks for your help!

Activity icon

Replied to Extra Slash In The Route

@ara glad I helped you. If this worked for you, you can mark the answer as best, so this thread will be marked as solved

Activity icon

Replied to Implementing A Simple Animated Checkbox On Click (like Laracasts)?

@connecteev I've updated the Pen with some Alpinejs, now the radio button is more interactive

Activity icon

Replied to Extra Slash In The Route

@ara if your riot.txt file is in the public folder, you can access it without creating a route for it. Just like you will access your robots.txt file in the public folder.

If your want a route that downloads/shows a file from your storage folder, you should create a route like /file and return File::get(storage_path('path/riot.txt'));

Activity icon

Replied to Implementing A Simple Animated Checkbox On Click (like Laracasts)?

@connecteev glad it helped you :)

Maybe I'll add some alpinejs to make the checkbox interactive.

https://github.com/alpinejs/alpine

Activity icon

Awarded Best Reply on Implementing A Simple Animated Checkbox On Click (like Laracasts)?

@connecteev I've created a Codepen which contains this radio/select button. If you apply the div, you will see the animation. I hope this helps you.

You can apply this div in your application with some javascript.

https://codepen.io/DennisCodePens/pen/bGVMQbY

Activity icon

Replied to Implementing A Simple Animated Checkbox On Click (like Laracasts)?

@connecteev I've created a Codepen which contains this radio/select button. If you apply the div, you will see the animation. I hope this helps you.

You can apply this div in your application with some javascript.

https://codepen.io/DennisCodePens/pen/bGVMQbY

Activity icon

Replied to Notification::send With Non-existing User Model

@snapey yes, this method works fine, but it is just sending a notification/mail to an email address. I have a mail template where I set the greeting() like this ->greeting("Dear $notifiable->full_name"). Using the Notification::send() method this will work, because the send() method accepts a collection of User models.

Making a new User model will do the trick you think, but when queueing the Notification, you get that No query results for model error.

So the simple question is, is it even possible to use the Notification::send() method when using a non-existing User. For now it won't work, but is there a way to avoid this error, if not, then I have to do it with the "On Demand Notifications".

Activity icon

Replied to "554 5.5.1 Error: No Valid Recipients" On Password Reset

@loomix a tip to make sure the connection is set up correctly is to connect to https://mailtrap.io/ for example. If that connection works, then you have configured the settings with the wrong credentials of your own mail host/provider.

Activity icon

Replied to "554 5.5.1 Error: No Valid Recipients" On Password Reset

@loomix what I mean is that you directly entered the username/password in the env() function like this:

'username' => env('mx5xxxe41'),
'password' => env('xxxxxxx')

But this won't work, you have to refer to the env variable file instead of passing the credentials directly.

Activity icon

Replied to "554 5.5.1 Error: No Valid Recipients" On Password Reset

@loomix I noted the following lines in your mail.php file:

'username' => env('mx5xxxe41'),
'password' => env('xxxxxxx')

This env() function should not receive the actual credentials but the config name in your env file

so it should look like this in your config/mail.php;

'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD')
Activity icon

Replied to "554 5.5.1 Error: No Valid Recipients" On Password Reset

@loomix check the mail address your are sending to is a valid email address. It looks like the problem is that you try sending an email to a non-existing or non-valid email address

Activity icon

Replied to Notification::send With Non-existing User Model

@oli_d111 Thanks again for your replay.

Your solution is almost what I have applied as alternative. I can easily add some data to the event/notification class and then apply that data in my mail.

I was just wondering if it is possible to create a custom User model with only an name/email and merge this user model to the admin User models, so I can send emails in one line instead of calling the Mail class twice (for admins and custom email addresses). But that is not possible I guess.

But thanks anyway for your help. And about the event/listeners, you're right. I have to set them, but for now it is working too :)

Activity icon

Replied to Customising A Module

Hi @rffred

It depends on what exactly you need to change/extend. I don't fully understand what your change would be. But when you require a package, you'll always have the choice to overwrite methods/properties etc. (If your package allows it). So maybe you can reply with a short code snippet what you want to customize to one of the sites, so I fully understand it.

To come back to your question, you should create a new model in your application, this model extends the model of your package, like in the example of my previous reply.

When you create such a model and extend the model from the package, you can add those extra properties/methods you need in your application..

But a code snippet would be helpful :)

May
09
5 months ago
Activity icon

Replied to Customising A Module

Hi @rffred,

In this case you can easily overwrite the properties of the loaded model.

let's say you are using the Admin model in your application and for one of the two applications you need to modify the Admin model.

You can create a new Admin model in one of that projects, if you haven't already done it. Extend that model from your Admin model of the package and add your custom properties.

use vendor\Models\Admin as AdminModel

class Admin extends AdminModel
{
    public function yourCustomFunction()
    {
        // your logic
    }
}
Activity icon

Replied to Notification::send With Non-existing User Model

@oli_d111 thanks for your reply.

What I'm trying to achieve is to send email notifications to existing and non-existing Users.

What is the case:

  1. I have a list of existing Users in the database, these are for example the admins
  2. I have a custom email address, which is filled in by the end-user (just an input field for email).

Now I know that Larvavel doesn't let you send Email notifications to just an email address when using the Notification::send() method =, you need to use the Notification::route() method.

So for the custom email addresses I created a User Object:

// Just an example

$email = request('email');
$name = request('name');
$user = User::make(['email' => $email, 'name' => $name]);

Notification::send($user, new CustomNotification()); // queued notification
// Gives error: No query results for model

Now you see the result, this approach always returns an No query results for model error when running the queue.

My question is, is it even possible to do something like this, sending Notifications to a collection of user models, which contains non-existing users.

Why? It is because of for example the greeting, I want to use the $notifiable variable to get the name of the user, but with the Notification::route() method, you'll never be able to get the name of that $notifiable

I hope this is a bit more clear. If you say, your approach is wrong, use another way to retrieve a custom inserted email/name I fully understand, but I would hear your thoughts about it :)

And yes, the hardcoded ID's are just for example purpose.

The first thing I've learned is never use hardcoded id's in your app. ( I maintained a lot of apps which contained hardcoded data in it, which causes very much problems over time ^^)

May
08
5 months ago
Activity icon

Awarded Best Reply on Dynamic SVG File

@philipbaginski based on your question, I think creating a svg.blade.php file and pushing that resource to the blade, and using the variables for the dynamic values, will work for you.

Activity icon

Replied to How To Disable A Href After Submit Until Action Is Complete

@noblemfd you shouldn't use an a href button to submit forms.. Just change the a href to a real button.

Then to achieve this, you can add an event listener on that button like so:

<button id="publishButton" type="submit" class="btn btn-primary" onclick="disableButton(this)">Publish</button>

function disableButton(btn){
    document.getElementById(btn.id).disabled = true;
}
Activity icon

Replied to How To Update Resource Detail View Without Reloading The Whole Page In Laravel Nova?

@eshopguru try updating the status when you get a success response with axios by using querySelector.

Another approach is using Laravel LiveWire, you should take a look at it. https://laravel-livewire.com/

Activity icon

Replied to Problem With Request Inserting Null Values In Database

@dr24 It seems that the $request->name is empty, can you output your $request parameter?

public function updateTvOptions(UpdateTvOptionsRequest $request)
{
    dd($request->all());
}
Activity icon

Replied to Dynamic SVG File

@philipbaginski yes indeed. You'll see this approach more when developing and using components

If this solves your question, please mark the answer as "Best answer" :)

May
07
5 months ago
Activity icon

Replied to Can Migrate DB, But On Insert Get: Access Denied For User 'root'@'localhost'

@corbin Try removing password from the DB_PASSWORD in your .env file. If you cached your config, run php artisan config:cache and try creating the record again.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_spa
DB_USERNAME=root
DB_PASSWORD=
Activity icon

Replied to Saving Google Map Embed Code

@dtommy79 does it save nothing at all or wrong formatted iframe?

If it is saving nothing to the map column, please check your Settings model if the map is added to the $fillable array.

Activity icon

Replied to 'Detatching' The Migrations And Seeders

@dylandd you want to separate the migrations and seeders, so you can share them between the website and the app?

If so, I don't think it does really make sense. Here is why.

When changing/adding a migration to your Laravel website, you should add it to your Lumen project too, so these are 2 actions. That's why you want to separate it in a single project.

Now when you have separated the migrations and seeders, you update the migrations in your single package (1 action), you need to update this package in both Laravel and Lumen projects (+2 actions) and then publish the new migrations (+2 actions) and run the seeders.

So instead of both migrations/seeders in both projects which takes you 2 actions in total, you separate them which will take you 5 actions. So I don't think separating the migrations into a single project will speed up your work and actions.

I think the best way is to keep the migrations and seeders in both projects, so you have full control over those files. If in the future the app will change some data, you can just update the migrations for the app, and your Laravel website keeps untouched.

The best way I prefer is building a global API for your website and your app. Your Laravel website will contain the public API which is used by the website itself, and the Lumen app can make use of the same api, to retrieve all needed data. Now you don't need to create the same database for the Lumen app but use the Laravel API instead.

Activity icon

Replied to Errors With Middleware And Action Form

@anthonykamers I don't know how the other routes looks like, but I know that Laravel will read the routes from top to the bottom, so the last (duplicated) route will be picked.

Always make sure you named your routes, so it is easier to access them and prevent duplicating issues.

Maybe you can print the output of your php artisan route:list, where you can see if there are any duplicated routes/action names.

Activity icon

Replied to How Do You Make A Factory For A Model With A Foreign Id?

@ilijatatalovic the create() method actually save the model to the database, the make() model returns a newly model, without saving it to the database.

I just tested the approach with create() and it turns out the profiles won't be added twice into the database, but it is a wrong approach since you just want to provide a $profile object and not actually saving it to the database, because the $user->profile()->save() does this for you.

https://laravel.com/docs/7.x/eloquent-relationships#the-save-method https://laravel.com/docs/7.x/database-testing#relationships

Activity icon

Awarded Best Reply on Errors With Middleware And Action Form

@anthonykamers

It's because of the action="{{ action('[email protected]') }}" It tries to find the route with that same controller and action name. Since you have two routes with the same name, it gets the last one in the routes file.

Try using a route name instead:

// web.php
Route::middleware('admin')->group(function () {
    Route::get('/admin/os-finalizada', '[email protected]')->name('admin-finalizada-show');
});
// finalizados.blade.php
<form action="{{ route('os-finalizada-show') }}" method="GET">
Activity icon

Replied to How Do You Make A Factory For A Model With A Foreign Id?

@ilijatatalovic when using the create() instead of the make(), the factory will create 2 profiles per user.

One in the $u->profile()->save()

and one from the factory it self factory(App\Profile::class)->create()

Activity icon

Replied to Using OAUTH2 Scopes With RBAC

@bahjaat I merged the front-end and backend together. So users which are authenticated, can directly retrieve data and routes from te application, so no api call is needed anymore.

I came to the conclusion that we didn't need to separate the front-end and backend. And we have no 3rd-party users which will access our api.

So I don't think this is the answer you was for, but was my solution.