0

I tried to update a record with this code but no success, i have this error message ... this is probably not the right method

public function update(Request $request, int $id)
{
    // dd($id, $request);
    
    $article_data = array();

    foreach ($this -> locales as $locale)
    {
        $article_data[ $locale ] = array(
            'title' => $request -> input( $locale . '_title'),
            'content' => $request -> input( $locale . '_content')
        );

    }

    Article::update($article_data);

    return redirect()->route('admin.article.home');
}

But when I tried this, I receive this error

ErrorException Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically

I understand that the update method is not the correct one ... So any help would be appreciated :) Thank you

this is an example of article_data structure

        $article_data = [
        'fr' => [
            'title'       => $request->input('fr_title'),
            'content' => $request->input('fr_content')
        ],
       'en' => [
           'title'       => $request->input('en_title'),
           'content' => $request->input('en_content')
       ],
    ];
Arnauld
  • 1
  • 1

1 Answers1

-1

Here is the solution

public function update(Request $request, Article $id)
{
    $id->update( $request->all() );

    return redirect()->route('admin.article.home');
}

Thank you :)

Arnauld
  • 1
  • 1