Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flexibility to allow the application to modify the model before saving #147

Open
wants to merge 1 commit into
base: 3.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/LaravelFacebookSdk/SyncableGraphNodeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ trait SyncableGraphNodeTrait
* @throws \InvalidArgumentException
*/
public static function createOrUpdateGraphNode($data)
{
$graph_node = static::convertGraphNodeToModel($data);

$graph_node->save();

return $graph_node;
}

/**
* Converts Graph node into a Model so that any changes can be done before saving
*
* @param $data
*
* @return Model
*
* @throws \InvalidArgumentException
*/
public static function convertGraphNodeToModel($data)
{
// @todo this will be GraphNode soon
if ($data instanceof GraphObject || $data instanceof GraphNode) {
Expand All @@ -55,8 +73,6 @@ public static function createOrUpdateGraphNode($data)

static::mapGraphNodeFieldNamesToDatabaseColumnNames($graph_node, $data);

$graph_node->save();

return $graph_node;
}

Expand Down