Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 399
Zeile 7... Zeile 7...
7
    /**
7
    /**
8
     * All of the extensions to be added to the builder.
8
     * All of the extensions to be added to the builder.
9
     *
9
     *
10
     * @var string[]
10
     * @var string[]
11
     */
11
     */
12
    protected $extensions = ['Restore', 'WithTrashed', 'WithoutTrashed', 'OnlyTrashed'];
12
    protected $extensions = ['Restore', 'RestoreOrCreate', 'WithTrashed', 'WithoutTrashed', 'OnlyTrashed'];
Zeile 13... Zeile 13...
13
 
13
 
14
    /**
14
    /**
15
     * Apply the scope to a given Eloquent query builder.
15
     * Apply the scope to a given Eloquent query builder.
16
     *
16
     *
Zeile 73... Zeile 73...
73
            return $builder->update([$builder->getModel()->getDeletedAtColumn() => null]);
73
            return $builder->update([$builder->getModel()->getDeletedAtColumn() => null]);
74
        });
74
        });
75
    }
75
    }
Zeile 76... Zeile 76...
76
 
76
 
-
 
77
    /**
-
 
78
     * Add the restore-or-create extension to the builder.
-
 
79
     *
-
 
80
     * @param  \Illuminate\Database\Eloquent\Builder  $builder
-
 
81
     * @return void
-
 
82
     */
-
 
83
    protected function addRestoreOrCreate(Builder $builder)
-
 
84
    {
-
 
85
        $builder->macro('restoreOrCreate', function (Builder $builder, array $attributes = [], array $values = []) {
-
 
86
            $builder->withTrashed();
-
 
87
 
-
 
88
            return tap($builder->firstOrCreate($attributes, $values), function ($instance) {
-
 
89
                $instance->restore();
-
 
90
            });
-
 
91
        });
-
 
92
    }
-
 
93
 
77
    /**
94
    /**
78
     * Add the with-trashed extension to the builder.
95
     * Add the with-trashed extension to the builder.
79
     *
96
     *
80
     * @param  \Illuminate\Database\Eloquent\Builder  $builder
97
     * @param  \Illuminate\Database\Eloquent\Builder  $builder
81
     * @return void
98
     * @return void