laravel-medialibrary: SQL Error when getMedia()

Hello. I’m having this SQL error when I try to get the media from my model.

>>> $user = App\Models\User::find(301);
=> App\Models\User {#834
     id: "301",
     username: "username",
     email: "email@domain.lo",
     first_name: "Jon",
     last_name: "Snow",
     birthday: null,
     phone: null,
     phone_mobile: null,
     country: null,
     state: null,
     city: null,
     gender: "MA",
     biography: null,
     nationality: null,
     occupation: null,
     relationship: null,
     education: null,
     created_at: "2017-09-22 22:58:58",
     updated_at: "2017-09-22 22:58:58",
     verified: "0",
     verification_token: null,
   }`

`
>>> $user->getMedia()
Illuminate\Database\QueryException with message 'SQLSTATE[HY000]: General error: 2036  (SQL: select * from `media` where `media`.`model_id` = 301 and `media`.`model_id` is not null and `media`.`model_type` = App\Models\User)'
>>> 

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (5 by maintainers)

Most upvoted comments

@alederzz Yes it works well.

Hey! Forget about everything. I just found out why it’s happening. Oh, and it is so stupid. ~shame on me~

For some reason, the MySQL docker image came with the charset configured by default as latin1. I just change the charset to the correct one and everything works fine.

Dude, I lost at least 3 hours with this problem. Just 'cause this dammit mysql image came with latin1 instead utf8…

Thank you guys, for your support. Oh, and I’ll make a pull request later to give an extra support to the library.