Created
December 18, 2019 16:43
-
-
Save dvlpp/81b4963b8036e3c4a0eb470f8544f992 to your computer and use it in GitHub Desktop.
PilotSharpForm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PilotSharpForm extends SharpForm | |
{ | |
use WithSharpFormEloquentUpdater, WithSharpContext; | |
// [...] | |
function update($id, array $data) | |
{ | |
$pilot = $id ? Pilot::findOrFail($id) : new Pilot; | |
$pilot = $this->save($pilot, $data); | |
if($this->context()->isCreation()) { | |
if($breadcrumb = $this->context()->getPreviousPageFromBreadcrumb("show")) { | |
list($type, $entityKey, $instanceId) = $breadcrumb; | |
if ($entityKey == "spaceship") { | |
Spaceship::findOrFail($instanceId)->pilots()->attach($pilot->id); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment