Skip to content

Instantly share code, notes, and snippets.

@elishaukpong
Created May 2, 2022 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elishaukpong/5434f8fc40ec96c2f0140c6510ed68be to your computer and use it in GitHub Desktop.
Save elishaukpong/5434f8fc40ec96c2f0140c6510ed68be to your computer and use it in GitHub Desktop.
<?php
//With exceptions
try {
$model->name = "Elisha";
$model->save();
} catch(ModelFailedToSaveException $e){
//Handle the exception
echo "It failed to save"
}
//Without exceptions
$model->name = "Elisha";
if( ! $model->save()){
//Handle the exception
echo "It failed to save"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment