SammyK / LaravelFacebookSdk

Fully unit tested Facebook SDK v5 integration for Laravel & Lumen
MIT License
693 stars 201 forks source link

array_dot notation not working #180

Open IllesAprod opened 7 years ago

IllesAprod commented 7 years ago

Hi Guys!

The array_dot notation not working for me.

My model:

   protected static $graph_node_fillable_fields = ['fb_id', 'fb_creator_id', 'message', 'story', 'fb_creator_name'];

    protected static $graph_node_field_aliases = [
        'id' => 'fb_id',
        'message' => 'message',
        'story' => 'story',
        'from.id' => 'fb_creator_id',
        'from.name' => 'fb_creator_name',
    ];

And it dont save from.id and from.name to the database using createOrUpdateGraphNode.

If i convert fields with array_dot helper in mapGraphNodeFieldNamesToDatabaseColumnNames function than it is working fine

    public static function mapGraphNodeFieldNamesToDatabaseColumnNames(Model $object, array $fields)
    {
//convert fields to array_dot notation
        $fields = array_dot($fields);

        foreach ($fields as $field => $value) {
            if (static::graphNodeFieldIsWhiteListed(static::fieldToColumnName($field))) {
                $object->{static::fieldToColumnName($field)} = $value;
            }
        }
    }

Am I using it wrong or is it a known issue?

Regards, Aprod