php - Laravel Eloquent to treat the column 'archived_at' like it does 'deleted_at' -
I am trying to get a new column called 'archived_at' in the same way as Laravel The way 'deleted_at' is behaving i.e., when I run a query, I do not want to select any archived record as long as I do not explicitly tell it (i.e., only invoice: only fixed () -> Pagnet ()). In other words, the archived_at behavior should be made in Laravel to duplicate the soft removal behavior.
I'm looking at Laravel's builder and soft blasting functionality made in model classrooms. Even what I have so far:
- Increase the model class and add the archived_at functionality to the new category.
- Update app / config.php alias:
// 'supernatural' = & gt; 'Brighten up \ database \ eloquent \ model', 'aloquent' = & gt; "CoreExtensions \ Model",
I can not know how to expand the builder class and read Laravel from the Extended Builder class if I can remove it, So maybe I can rest. Any suggestions? thank you in advanced!
You probably only need to do something extraordinary and do something like this:
< Code> & lt ;? Php class unsuspecting {return with archive (new static) with public static function - & gt; New form (true, true); } Public static function only with fixed () {back (new static) - & gt; New form (wrong, wrong, true); } / ** * Get a new query builder for a table of models * * @ Ultimate Bull $ Excluded Deleted * @ Walking \ Database \ Supernatural \ Builder | Static * / public function newQuery ($ Excluded Deleted = true, $ Excluded = true, Only $ fixed = false) {$ builder = $ this- & gt; NewEloquentBuilder ($ this- & gt; newBaseQueryBuilder ()); // When we have query builders, we will set model examples so that // builder will be able to easily use any information from that model when it is creating and executing various questions against it. $ Builder- & gt; SetModel ($ this) - & gt; (; With $ this- & gt;); If (! $ Only stored) {If ($ Excluded Deleted & amp; $ this- & gt; Delete Soft) {$ builder- & gt; Jahal ($ this-> getQualifiedDeletedAtColumn ()); } If ($ Excluded) {$ builder-> Where not ('archived_at'); }} And {$ creator-> jnnoton ('archived_at'); } Return creator $; }}
And then you will probably be able to:
Invoice :: Only Archels () - & gt; Endorse (); Invoice :: with Authorized () - & gt; Where ('customer_id', $ customer_id) - & gt; Endorse ();
Comments
Post a Comment