soso-_-'s avatar
Level 11

Hands On: Community Contributions | Episode 2 - Display Community Links

Hi guys, in my CommunityLinksController when I want to fetch the data from the database to my $links variable it returns a pagination with an empty collection of items. (I did dd($links) to observe it)

In the video it starts from 2min07s to the expected result at 5min02s Ofc I defined the CommunityLink factory and edited the views/community/index.blade.php.

Could you please help me to understand why ?

0 likes
3 replies
James_Moore's avatar

hey @soso-_- can you post the code your having trouble with, I'm having a hard time understanding what your problem is exactly. Is the problem that the $links variable your passing from your controller to your view is empty when you feel it shouldn't be. please use the

``` code goes here syntax ```

to post your model code, controller code and view, and even the factory. You may want to directly check your database community_links table if that what you named it to make sure there is data in it.

soso-_-'s avatar
Level 11

Hey @james_moore , thanks for your answer. My code is identical to the one jeff typed.

I continued the serie and at the Episode 3 I was able to create and fetch my data.

At this point I noticed that my app is not using the database I set in the .env file, instead it's using the default "laravel" one.

So, I partially solved the problem because now I understand I was trying to fetch data from the "laravel" database which was empty.

Now I'm wondering why it's not using the database I did set in the .env file "DB_DATABASE=voting_lesson"

How does that sound to you?

soso-_-'s avatar
soso-_-
OP
Best Answer
Level 11

Hum... Ok, in fact I found that "The database configuration for your application is located at config/database.php. In this file you may define all of your database connections, as well as specify which connection should be used by default."

So, the problem is solved. I needed to configurate the database as shown above.

Please or to participate in this conversation.