Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not null violation: 7 ERROR: null value in column "contentable_id" #9

Closed
emexxRepo opened this issue Apr 30, 2019 · 3 comments
Closed

Comments

@emexxRepo
Copy link

Hello
Im using postgreSql

MYcode ---

$rawContent = Contract::find(1);
if (empty($rawContent)) {
$contract = new Contract();
$contract->mycontent = "TestCon";
$contract->save();
$rawContent = Contract::find(1);
}

    $model = new Contract();
    $model->setContent($rawContent,true);

i have a problem while i am saving raw content throw below error
"
SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "contentable_id" violates not-null constraint DETAIL: Failing row contains (9, null, null, App\Contract, null, page, 2019-04-30 09:45:19, 2019-04-30 09:45:19). (SQL: insert into "lb_contents" ("contentable_id", "contentable_type", "updated_at", "created_at") values (, App\Contract, 2019-04-30 09:45:19, 2019-04-30 09:45:19) returning "id")

"

help me

@mauricewijnia
Copy link
Member

mauricewijnia commented Apr 30, 2019

I'm not exactly sure what you're trying to do here but this should work if you're trying to create a new 'Contract':

$contract = new Contract();
$contract->setContent("TestContent", true);
$contract->save();

Hope that helps, and good luck!

@JunaidQadirB
Copy link

JunaidQadirB commented May 6, 2019

So do I fill other fields like this?

$contract = new Contract();
$contract->setContent("TestContent", true);
$contract->field1='Value1'; //Additional field defined in the Contracts model
$contract->save();

@JunaidQadirB
Copy link

I'm not exactly sure what you're trying to do here but this should work if you're trying to create a new 'Contract':

$contract = new Contract();
$contract->setContent("TestContent", true);
$contract->save();

Hope that helps, and good luck!

I'm not exactly sure what you're trying to do here but this should work if you're trying to create a new 'Contract':

$contract = new Contract();
$contract->setContent("TestContent", true);
$contract->save();

Hope that helps, and good luck!

$contract->save();

should be called before

$contract->setContent("TestContent", true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants