I am using jwt in luman and use primary key UUID hexadecimal.
And firstly i got issues to Authenticate token by passing in header the issue was -
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.id' in 'where clause' (SQL: select * from user` where users.id = 0 limit 1) "
but i solved it using " protected $primaryKey = 'uuid'; " put in model it fine.
But after i got another issue in 'jwt->attemp' it always give my UUID '30' in numeric number when i login but when i remove the code form model it's working fine. Please help me about this issues.
In your config/jwt.php change:
'identifier' => 'id'
To
'identifier' => 'uuid'
Related
While creating my database according to the eloquent standard, I ran into the problem that my table_name and id column name combined would be longer as 64 characters.
very_long_table_name.very_long_column_name_id
So I used a shorter column name as the foreign key in my Intermediate Table.
Migration file:
$table->unsignedBigInteger('short_id');
$table->foreign('short_id')->references('id')->on('very_long_table_name');
That worked fine, yet now I would like to insert a connection
Seeder.php:
$x->very_long_table_name()->attach($other_table_name->id);
I get the error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'very_long_column_name_id' in 'field list' (SQL: insert into very_long_table_name (just_an_id, very_long_column_name_id) values (1, 1))
What I would want is that it would use the column short_id instead of very_long_column_name_id to insert this, is there any cool way to fix this? or do I need to insert and query the connection manually if I keep the long names?
Like #Tim points out in the comments this needs to be done in the Model VeryLongTableName.php where you define the relationship:
public function very_long_table_name() {
return $this->belongsToMany(Model::class, 'very_long_table_name', 'local_id', 'short_id');
}
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Update_Profile' in 'field list' (SQL: update users set updated_at = 2021-01-11 00:01:39, Update_Profile = Update Profile where id = 12)
I am getting this error whenever a user tries to update his/her profile.
This is where the user click the UPDATE PROFILE
And this is the error I am getting
And I think the error is from here but I don't now
Can someone help me out please.
If update_profile is available in your table and you got that error probably this will be sloved with one of two ways below:
1 - Run command 'composer dumpautoload' in the terminal
2 - Clear this path contents : \storage\framework\views*
I am stuck with a situation where i coudn't update my records using Eloquent in Laravel 5.5 using custom primary key.
Here is what i tried :-
In my Model.php i have,
protected $primarykey = 'custom_primary_key';
my migrations looks like :-
$table->increments('custom_primary_key');
in my controller,i have :-
Model::find(custom_primary_key);
but when i tries to find a record using find() in my controller, it gives
Column not found: 1054 Unknown column 'table.id' in 'where clause' (SQL: select * from `table` where `table`.`id` = 1 and `table`.`deleted_at` is null limit 1)"
table also contains a column with custom primary key and there is no column named id.
It doesnt recognize the cutom primary key. Where can i be missing something ?
Set $primarykey into $primaryKey. Check the documentation from Laravel here:
https://laravel.com/docs/5.6/eloquent#eloquent-model-conventions
I am doing a basic project in Laravel, when trying to delete an entry, it generates this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from `employees` where `id` = 6 limit 1)
and it is true I don't have a column named 'id', instead I have employee_id, but why is it choosing id instead of employee_id?
Please explain from where did it bring this id column?
In your Employee model (Employee.php), add
protected $primaryKey = 'employee_id';
This will tell Laravel to use employee_id as the primary key for Empolyee objects.
I have wierd trouble during validating request in controller. I use exists validation rule. User is supposed to submit integer. This integer should exist as id in a single row of user_courses table. This row also should have column user_id equal to 158 - docs.
My validation rule:
'course_id' => 'integer|exists: user_courses, id, user_id, 158'
What I got instead:
PDOException in Connection.php line 333: SQLSTATE[42S22]: Column not
found: 1054 Unknown column ' id' in 'where clause'
My Table:
id, user_id, created_at, updated_at
Problem was in the spaces:
'course_id' => 'integer|exists: user_courses, id, user_id, 158' // incorrect
'course_id' => 'integer|exists:user_courses,id,user_id,158' // correct
Original code would confuse laravel to search for column names like this:
' user_courses'