Volka Dimitrev :
I'm trying to run a update function in my laravel app but every time when i run the function it gives me this error,
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: update `apps` set `domain` = Testinput.test.com, `apps`.`updated_at` = 2020-03-30 13:18:32 where `id` is null)
Here is my update function in the controller,
public function update(Request $request,App $app, $id)
{
$this->validate($request, [
'domain' => ['required', 'string','min:2', 'max:255'],
],$request->all());
$fullDomain = $request->domain;
$app->domain=$fullDomain;
$app = App::where('appId','=','1')->first()->update($request->all());
return Redirect::back()->with('success',__('sentence.User updated successfully'));
}
I dont't have a column called id in my apps table my column is appId
Dan :
You gotta inform Laravel that you're using a different primary key from what it's expecting:
In your App model add the $primaryKey
property along with the name of the primary key you're using in your database:
class App extends Model
{
protected $primaryKey = 'appId';
}
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=394986&siteId=1