質問

I'm trying to submit updates to items in the Items model. However, Ardent never actually performs the updates when the update method receives them but doesn't throw an error:

public function update($id)
{
    $item = Item::findOrFail($id);

    if ($item->save()) {
        return Redirect::back()->with('message', "Item #$id updated!");
    } else {
        return Redirect::back()->withInput()->withErrors($item->errors());
    }
}

What is wrong with my controller logic here?

役に立ちましたか?

解決

It looks like you need to set those variables

class Item extends \LaravelBook\Ardent\Ardent {
    // hydrates on new entries' validation
    public $autoHydrateEntityFromInput = true;    
    // hydrates whenever validation is called
    public $forceEntityHydrationFromInput = true; 
}

properly to get the behavior you expect.

Source: https://github.com/laravelbook/ardent#automatically-hydrate-ardent-entities

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top