PHP - How can I refactor this store function (which handles different database operation for user types) in order to reduce duplication?
I think it's a very good case to employ OOP, namely polymorphism and inheritance.

First, we've got to create a dedicated class to handle the user preferences.

A common ancestor to hold all the common code

abstract class UserPreferences
{
    protected $userId;
    protected $db;

    public function __construct($userId, $db) {
        $this-&gt;userId = $userId;
        $this-&gt;db = $db;
    }
    protected function addGeneric($preferences) {
        $sql = "INSERT INTO preferences (...) VALUES (?,?,?)";
        $this-&gt;db-&gt;prepare($sql)-&gt;execute($preferences);
    } 

    abstract protected function addSpecific($preferences);

    public function add($preferences)
    {
        $this-&gt;db-&gt;beginTransaction();

        try {
            $this-&gt;addGeneric($preferences);
            $this-&gt;addSpecific($preferences);
            $this-&gt;db-&gt;commit();
        } catch(Throwable $e){
            $this-&gt;db-&gt;rollBack();
            throw $e;
        }
    }
}


and then implementations for different types

class AdminPreferences extends UserPreferences 
{
    protected function addSpecific($preferences) {
        $sql = "INSERT INTO admin_preferences (...) VALUES (?,?,?)";
        $this-&gt;db-&gt;prepare($sql)-&gt;execute($preferences);
    }
} 

class SalesPreferences extends UserPreferences 
{
    protected function addSpecific($preferences) {
        $sql = "INSERT INTO sales_preferences (...) VALUES (?,?,?)";
        $this-&gt;db-&gt;prepare($sql)-&gt;execute($preferences);
    }
} 


...and so on.

Then in the User class create an instance of the Preferences class

class User 
{
    public $preferences;
    public function __construct($db, $type) {
        $this-&gt;userId = $userId;
        $this-&gt;db = $db;
        $this-&gt;preferences = $this-&gt;setPreferences($db, $type);
    }
    protected function setPreferences($db, $type) {
        switch($type) {
            case 'Admin':
                $this-&gt;preferences = new AdminPreferences($db);
                break;
            case 'Sales':
                $this-&gt;preferences = new SalesPreferences($db);
                break;
        }
    }
}


the same goes for the statistics

and finally in your controller simply 

$preferences = $parsedBody['preferences'];
$this-&gt;User-&gt;preferences-&gt;add($preferences);
$this-&gt;User-&gt;preferencesStatistics-&gt;add($preferences);

return $response-&gt;withJSON([
    "error" =&gt; false, 
    "message" =&gt; "operation completed successfully"
    "data" =&gt; null
]);


Note that checking $preferenceAdded manually is not the way to go. There should be a dedicated error handler to do the job.