Quantcast
Viewing latest article 4
Browse Latest Browse All 12

Laravel Relation “Attempt to read property on null”

It usually means that the related record is NULL or soft-deleted. There are multiple ways to gracefully handle such a situation, without showing the error to the user. A practical example would be a list of Posts with belongs To relation to Categories. Migration file for Posts: [crayon-66a3aad11e527163558677/] app/Models/Post.php: [crayon-66a3aad11e52d588890111/]   app/Http/Controllers/PostController.php: [crayon-66a3aad11e52e339787386/]   resources/views/posts.blade.php: …

Continue reading

Source


Viewing latest article 4
Browse Latest Browse All 12

Trending Articles