Upgrading from 9.x to 10.x
The upgrade command
Sharp 10 comes with an upgrade command that replaces and notifies for deprecated and removed code. You can run it with
bash
php artisan sharp:upgrade app/SharpWhere app/Sharp is the path of your sharp code.
Updating Dependencies
If you depend on them, you should update the following dependencies in your composer.json file :
inertiajs/inertia-laravelto^3.0(cf. https://inertiajs.com/docs/v3/getting-started/upgrade-guide)
Deprecated methods
Forms
Upload setImageCompactThumbnail() has no impact and can be removed:
php
\Code16\Sharp\Form\Fields\SharpFormUploadField::make('upload')
->setImageCompactThumbnail() Testing
The legacy testing API is deprecated and will be removed in 11.x. Please refer to (cf. Testing). Here are replacement examples:
php
uses(\Code16\Sharp\Utils\Testing\SharpAssertions::class)
it('test', function () {
$this->callSharpEntityCommandFromList(PersonEntity::class, MyCommand::class, ['attr' => 'some_value'])
$this->sharpList(PersonEntity::class)->entityCommand(MyCommand::class)->post(['attr' => 'some_value'])
$this->callSharpInstanceCommandFromList(PersonEntity::class, 1, MyCommand::class, ['attr' => 'some_value'])
$this->sharpList(PersonEntity::class)->instanceCommand(MyCommand::class, 1)->post(['attr' => 'some_value'])
$this->callSharpInstanceCommandFromShow(PersonEntity::class, 1, MyCommand::class, ['attr' => 'some_value'])
$this->sharpShow(PersonEntity::class, 1)->instanceCommand(MyCommand::class)->post(['attr' => 'some_value'])
$this->getSharpShow(PersonEntity::class, 1)
$this->sharpShow(PersonEntity::class, 1)->get()
$this->getSharpForm(PersonEntity::class, 1)
$this->sharpForm(PersonEntity::class, 1)->get()
$this->getSingleSharpForm(PersonEntity::class)
$this->sharpForm(PersonEntity::class)->get()
$this->updateSharpForm(PersonEntity::class, 1, [])
$this->sharpForm(PersonEntity::class, 1)->update([])
$this->storeSharpForm(PersonEntity::class, 1, [])
$this->sharpForm(PersonEntity::class, 1)->store([])
$this->updateSingleSharpForm(PersonEntity::class, [])
$this->sharpForm(PersonEntity::class)->update([])
$this->withSharpBreadcrumb(function (\Code16\Sharp\Utils\Links\BreadcrumbBuilder $builder) {
$builder->appendEntityList(PersonEntity::class)->appendShowPage(PersonEntity::class, 1)
})->getSharpForm(PersonEntity::class, 1)
$this->sharpList(PersonEntity::class)->sharpShow(PersonEntity::class, 1)->sharpForm(PersonEntity::class)->get()
})Removed classes and methods
Several features and methods that were deprecated in Sharp 9.0 have been removed to clean up the codebase.
General
- The
currentSharpRequest()helper and its associatedCurrentSharpRequestclass were removed. Usesharp()->context()instead (cf. Context). - The
SharpAuthenticationCheckHandlerinterface was removed. Use theviewSharpGate instead. - The
withSharpCurrentBreadcrumb()method inSharpAssertionswas removed. UsewithSharpBreadcrumb()instead. - Removal of "multi-forms". Replace all
SharpEntity::getMultiforms()implementations toSharpEntityList::configureEntityMap()instead (cf. Building entity list). - Smart handling of legacy fontaweome icons class has been removed. Tou must convert all
fa-occurences tofas-*,far-*,fab-*.
Configuration
- The legacy configuration handling based on the
sharp.phpconfig file was removed. You must now use aSharpAppServiceProviderwith aSharpConfigBuilder. SharpConfigBuilder::addEntity()has been removed in favor ofSharpConfigBuilder::declareEntity().
Forms
- The legacy
$formValidatorClassproperty handling inSharpFormwas removed. Implement theSharpForm::rules()andSharpForm::messages()methods instead (cf. Building form). Along with this removal, the following classes have been removed:\Code16\Sharp\Form\Validator\SharpFormRequest\Code16\Sharp\Form\Validator\SharpValidator\Code16\Sharp\Http\Middleware\Api\BindSharpValidationResolver(remove this from config)
- In
SharpFormUploadField, the following deprecated methods were removed:
php
\Code16\Sharp\Form\Fields\SharpFormUploadField::make('upload')
->setCropRatio()
->setImageCropRatio()
->shouldOptimizeImage()
->setImageOptimize()
->setTransformable()
->setImageTransformable()
->setFileFilterImages()
->setImageOnly()
->setFileFilter()
->setAllowedExtensions() - The
FormLayoutColum::withSingleField()&ShowLayoutColum::withSingleField()method was removed. UsewithField()orwithListField()instead. SharpFormDateField::setDisplayFormat()has been removedSharpFormAutocompleteFieldwas removed. Migrate to the followingSharpFormAutocompleteField::make('key', 'local')toSharpFormAutocompleteLocalField::make('key')SharpFormAutocompleteField::make('key', 'remote')toSharpFormAutocompleteRemoteField::make('key')
Entity Lists
- The
setWidthOnSmallScreens()andsetWidthOnSmallScreensFill()methods inEntityListFieldwere removed as they are no longer used in the new front-end table UI. - The
configureMultiformAttribute()method inSharpEntityListwas removed. UseconfigureEntityMap()instead.
Show
- The
configureMultiformAttribute()method inSharpShowwas removed. It's not used by sharp.
Filters
The following classes have been renamed / moved:
php
use \Code16\Sharp\EntityList\Filters\EntityListCheckFilter;
use \Code16\Sharp\Utils\Filters\CheckFilter;
use \Code16\Sharp\Filters\CheckFilter;
use \Code16\Sharp\EntityList\Filters\EntityListDateRangeFilter;
use \Code16\Sharp\Utils\Filters\DateRangeFilter;
use \Code16\Sharp\Filters\DateRangeFilter;
use \Code16\Sharp\EntityList\Filters\EntityListDateRangeRequiredFilter;
use \Code16\Sharp\Utils\Filters\DateRangeRequiredFilter;
use \Code16\Sharp\Filters\DateRangeRequiredFilter;
use \Code16\Sharp\EntityList\Filters\EntityListSelectFilter;
use \Code16\Sharp\Utils\Filters\SelectFilter;
use \Code16\Sharp\Filters\SelectFilter;
use \Code16\Sharp\EntityList\Filters\EntityListSelectMultipleFilter;
use \Code16\Sharp\Utils\Filters\SelectMultipleFilter;
use \Code16\Sharp\Filters\SelectMultipleFilter;
use \Code16\Sharp\EntityList\Filters\EntityListSelectRequiredFilter;
use \Code16\Sharp\Utils\Filters\SelectRequiredFilter;
use \Code16\Sharp\Filters\SelectRequiredFilter;