AndySong

Experience

28,180

0 Best Reply Awards

  • Member Since 4 Months Ago
  • 280 Lessons Completed
  • 0 Favorites

16th June, 2017

AndySong started a new conversation How Can I Return Boolean From Sql Result • 2 months ago

course_user is a pivot table, How can I know if there is a result that match the condition.

\DB::table('course_user')->where([
            ['course_id', '=', $course->id],
            ['user_id', '=', auth()->id()],
        ])

I mean how can I return it as true or false ! Thanks

AndySong started a new conversation Property * Does Not Exist On This Collection Instance • 2 months ago

I am tying to get course info from users by using a pivot table and the relationship is fine, when I did this

public function show(User $user)
    {
        return $user->courses;
    }

it shows [ { "id": 1, "course_id": "90c44fcb-e1b7-33da-9261-0ed5b42c03fe", "course_name": "Wava Oberbrunner", "created_at": "2017-06-16 07:31:06", "updated_at": "2017-06-16 07:31:06", "pivot": { "user_id": "1", "course_id": "1" } } ]

when I did this

    {
        return $user->courses->course_name;

    }

it shows Property [course_name] does not exist on this collection instance.

can anyone tell what is the easiest way to get the course_name ?Pls!

13th June, 2017

AndySong left a reply on Cannot Stream Laracast Videos • 2 months ago

all good for me too, maybe bad network?

12th June, 2017

AndySong left a reply on What Impacts I Can Get If I Do Not Write Return In A Function • 2 months ago

@mikevrind Thanks a lot for explaining me this simple question, I got it!!!

AndySong started a new conversation What Impacts I Can Get If I Do Not Write Return In A Function • 2 months ago

Hi I am new to programming, I am just wondering why that in Laravel in some functions I can get the same result whether I write "return" or not, like:

public function store ($channelId, Thread $thread) { return $thread->subscribe(); }

I can get the same result if I remove the "return".

can you guys tell me do I have to write return or it does not really matter?

cheers Andy

31st May, 2017

AndySong left a reply on Where Are You All From? • 2 months ago

any one from china???

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.