aleXela
aleXela

Reputation: 1301

Laravel eloquent return multiple values on first

Trying to return 1 row and get only couple column values of it:

public static function getLastUpdate(){
    return Settings::where('item', 'lastUpdate')->first()->value('item', 'created_at');
}

gives only value for 'item'.

pluck() not working here (gives new query on all table)

$hidden not good, since i'm using couple methods in same model.

didnt find in laravel docs. Thanks

Upvotes: 1

Views: 2977

Answers (1)

KDoX
KDoX

Reputation: 91

public static function getLastUpdate(){
    return Settings::where('item', 'lastUpdate')->first(['item', 'created_at']);
}

$setting = getLastUpdate();
echo $setting->item;
echo $setting->created_at;

Upvotes: 2

Related Questions