dfuncd / repofuck

Fucking with the Repository Design Pattern
6 stars 2 forks source link

Rewrite `setEntity` function #26

Closed rmrhz closed 8 years ago

rmrhz commented 8 years ago

Rewrite the setEntity function to accomodate certain functionalities that will improve usability cases

Improvements

Possible Future Use Cases

$keys = ['foo', 'bar'];

$foo->update($request->all(), $keys, function($repo)
{
    // assuming that from the request `bar` is an array
    $bar = $repo->setEntity('bar')->create($repo->data['bar'], array_keys($repo->data['bar']));
    $repo->pluckKeys(['bar'])->pushKeys(['bar_id'])->pushData(['bar_id' => $bar->id]);
});