File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -326,7 +326,6 @@ public function relationship(
326326 $ this ->loadStateFromRelationshipsUsing (function ($ record , PageBuilder $ component ) {
327327 /** @var Collection */
328328 $ blocks = $ this ->getConstrainAppliedQuery ($ record )
329- ->orderBy ('order ' )
330329 ->get ();
331330
332331 $ component ->state ($ blocks ->toArray ());
Original file line number Diff line number Diff line change 22
33namespace Redberry \PageBuilderPlugin \Models ;
44
5+ use Illuminate \Database \Eloquent \Attributes \ScopedBy ;
56use Illuminate \Database \Eloquent \Concerns \HasUuids ;
67use Illuminate \Database \Eloquent \Model ;
78use Illuminate \Database \Eloquent \Relations \MorphTo ;
89use Redberry \PageBuilderPlugin \Abstracts \BaseBlock ;
10+ use Redberry \PageBuilderPlugin \Models \Scopes \OrderScope ;
911
1012/**
1113 * @property string $id
1416 * @property string $page_builder_blockable_id
1517 * @property array $data
1618 */
19+ #[ScopedBy(OrderScope::class)]
1720class PageBuilderBlock extends Model
1821{
1922 use HasUuids;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Redberry \PageBuilderPlugin \Models \Scopes ;
4+
5+ use Illuminate \Database \Eloquent \Builder ;
6+ use Illuminate \Database \Eloquent \Model ;
7+ use Illuminate \Database \Eloquent \Scope ;
8+
9+ class OrderScope implements Scope
10+ {
11+ public function apply (Builder $ builder , Model $ model ): void
12+ {
13+ $ builder ->orderBy ('order ' )->orderBy ('created_at ' , 'desc ' );
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments