Building an application using MongoDb and Laravel 8.83
P粉155551728
P粉155551728 2024-03-31 22:18:53
0
1
293

I'm a beginner in php and Laravel, I'm trying to build this simple CRUD application using mongodb as database, I'm using https://www.mongodb.com/compatibility/mongodb-laravel-intergration as tutorial to learn how To do this I'm currently stuck on displaying data in laravel, I added the database to the application using:

'mongodb' => [ 'Driver' => 'mongodb', 'dsn' => env('DB_URI','mongodb srv://username:password@cluster0.npikk .mongodb.net/myappdb ?retryWrites=true&w=majority'),'database' => 'myappdb',], The name of the database is myappdb and the collection name is posts database view. All of this looks fine, but when I run the server and go to the post/first-blog-post route, I get an ErrorException Trying to get property 'Title' of non-object file directory It also marks line 7 in post.blade. Model position postal Post Controller controller network route route Why does this happen? There are better resources out there for creating CRUD applications (any simple application) in laravel using mongodb. Because I'm trying to learn but finding it difficult to follow without guidance or experience. All comments and ideas welcome.

P粉155551728
P粉155551728

reply all(1)
P粉994092873

Try a little debugging. I like to use the dd function and check what's in the variable. You may be accessing a property that does not exist in the collection. So just use the dd() function before letting the view display the output. Similar to dd(the_variable_I_want_to_check).

By the way, are you already familiar with MongoDB? If not, I recommend you take a quick look at this short introduction to MongoDB: Check it out here: https://www.youtube.com/watch?v=2QQGWYe7IDU

If you're okay with MongoDB, try checking out this playlist I found on Youtube via "Juniors Code Raw"

https://www.youtube.com/watch?v=J0Kc3qSrNlE&list =PLdTx40waQWgHIh3Kegr14vvSF-QsRd40J

There are actually only about 7 videos. Let me know how it goes.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!