Laravel: Mass search and update

adamj

Table: Settings

Columns: id, option and value

I was wondering if there is a way to search and update multiple rows in one go?

Something along these lines of:

Setting::find(array(
    'option' => 'name',
    'option' => 'address',
    'option' => 'phone'
))->save(array(
    Input::get('name'),
    Input::get('address'),
    Input::get('phone')
));
user1669496

Yeah, you can use the query builder to do this.

$updates = array(
    'name' => Input::get('name'),
    'address' => Input::get('address'),
    'phone' => Input::get('phone')
);

DB::table('settings')
        ->where('id', 1)
        ->update($updates);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related