docs icon indicating copy to clipboard operation
docs copied to clipboard

Add global scope for Winter 1.1.x version

Open webbati opened this issue 2 years ago • 1 comments

Global scopes documentation seem to refer only to Laravel 9.x (Winter 1.2.x), for previous version that are based on Laravel 6.x classes and methods are different (see https://laravel.com/docs/6.x/eloquent#global-scopes )

See issue https://github.com/wintercms/winter/issues/747

webbati avatar Oct 28 '22 16:10 webbati

@webbati maybe reference this in the PR:

https://laravel.com/docs/6.x/eloquent#global-scopes

mjauvin avatar Oct 28 '22 16:10 mjauvin

@webbati this doesn't seem right? The original code was documented 16 months ago, so it (assumedly) must've worked with Laravel 6. Your global scope example seems to just replace the Winter versions of the model, query and builder classes with the base Laravel classes. Could you explain more on why the original code examples did not work?

bennothommo avatar Oct 30 '22 22:10 bennothommo

@webbati my apologies, I read your linked issue and understand the problem now.

bennothommo avatar Oct 31 '22 00:10 bennothommo

Is it really necessary to change the class imports back to Illuminate or is it just required to make the booted() vs boot() change?

This should also be submitted to the 1.1 branch btw (https://github.com/wintercms/docs/tree/1.1), @bennothommo's new documentation site that will be out soon will allow you to switch between versions of the docs

LukeTowers avatar Nov 02 '22 17:11 LukeTowers

@LukeTowers Yes, it's necessary or you will get an error

Declaration of Concreta\Zuum\Scopes\OwnedScope::apply(Winter\Storm\Database\Builder $builder, Winter\Storm\Database\Model $model) must be compatible with Illuminate\Database\Eloquent\Scope::apply(Illuminate\Database\Eloquent\Builder $builder, Illuminate\Database\Eloquent\Model $model)

webbati avatar Nov 02 '22 18:11 webbati

@webbati can you resubmit this targeting only the 1.1 branch?

LukeTowers avatar Nov 29 '22 20:11 LukeTowers

@LukeTowers done https://github.com/wintercms/docs/pull/110

webbati avatar Nov 30 '22 16:11 webbati

Closed in favour of #111.

bennothommo avatar Dec 02 '22 01:12 bennothommo