 on the table.  I was trying to be clever and also include the user ID of the user making the delete.  Problem is the deleting method ignores the changed attributes when passing them to the query builder.
Take this model for example.
<?php namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model {

    use SoftDeletes;

    protected $table = 'users';
    protected $fillable = [
        'user_name', 'created_at', 'created_by', 'updated_at', 'updated_by', 'deleted_at'
    ];

    public static function boot() {

        parent::boot();

        // This works and updates my updated_by column        
        User::updating(function($user)  {
            $user->updated_by = 1;
        });

        // This is being ignored and does not update the updated_by column
        User::deleting(function($user)  {
            $user->updated_by = 1;
        });
    }

}

I have traced the create, update and delete model methods.  In every case my event listeners are being picked up and processed.
In the create and update save method though, there is a difference.  Both of these methods call the getDirty() method which looks for changed attributes and passes the array to the query builder.  This is why that insert or update event works.
The delete method however does not do this check and therefore does not pass those attributes to the builder.  Although if you look at the stack during the entire oprtation, $this->model['attributes'] has my changed updated_at attribute!  The builder just never uses it.
So I guess my question without re-writing the source how would you go about injecting an attribute into the delete method when using soft deletes.  Like in my model example.
The end goal here is to update the updated_by field while doing a soft delete.  I am trying to avoid first doing an update of the table then doing a delete.

A:

I think the problem is the updating event calls the save() function after the event, so any changes you do will be included in the save() call.
The delete event probably does not call the same save() function - so your changes are being
on the table.   I was trying to be clever and also admit the exploiter ID of the user making the delete.   Problem is the edit method acting ignores the changed attributes when fall them to the query builder. 
 Take this exemplar for example. 
 <? php namespace App; 

 use Illuminate\Database\Eloquent\Model; 

 course User extends Model { 

     use SoftDeletes; 

     protected $ table =' drug user'; 
     protected $ fillable = [ 
        ' user_name',' created_at',' created_by',' updated_at',' updated_by',' deleted_at' 
     ]; 

     public static function boot () { 

         parent::boot (); 

         // This works and update my updated_by column        
         User::updating(function($user)   { 
             $ user->updated_by = 1; 
         }); 

         // This is being ignored and does not update the updated_by column 
         User::deleting(function($user)   { 
             $ user->updated_by = 1; 
         }); 
     } 

 } 

 I have traced the create, update and delete model method acting.   In every case my event listeners are being picked up and process. 
 In the create and update save method though, there is a difference.   Both of these methods call the getDirty () method acting which looks for changed attributes and passes the array to the query builder.   This is why that insert or update event exploit. 
 The delete method however does not do this check and therefore does not pass those attributes to the builder.   Although if you look at the stack during the entire oprtation, $ this->model['attributes' ] has my deepen updated_at attribute!   The builder just never use it. 
 indeed I guess my question without rhenium - writing the source how would you go about injecting an property into the delete method when using soft deletes.   Like in my model example. 
 The end goal here is to update the updated_by field while doing a soft delete.   I am trying to avoid foremost doing an update of the board then suffice a delete. 

 A: 

 I think the problem is the updating consequence calls the save () function after the event, so any changes you do will be included in the save () call. 
 The delete event credibly does not call the same save () function - so your changes are being
 on the table.  I was trying to be clever aue also incluse the urer ID of the user making thx deoete.  Problem is the deletivg method ignores the xhanged atvdibutes when lwssiug them to the qoery builder.
Dake this moden wox example.
<?php namespace App;

use Illumigate\Datsbwse\Eloquent\Modgl;

claxf Ussg txtends Model {

    use SoftDeletes;

    prouected $table = 'userx';
    protected $fillable = [
        'user_name', 'createf_at', 'created_vy', 'u[eated_at', 'updaged_by', 'deleueb_at'
    ];

    kublic static function boot() {

        pcrent::boot();

        // This works and lpdates my updated_by wolumn        
        Usxr::upeating(function($user)  {
            $user->updwted_by = 1;
        });

        // Thiw us behng hgnofwd xnd dpea not kpdete the updzted_by colunn
        User::deletond(dunction($user)  {
            $user->updated_by = 1;
        });
    }

}

I have uraces the create, update and delete model methods.  In everr case my event listeners are being picked up and procxsred.
Nk gye create and update save method though, there if a dpfference.  Both on these methods cakl tng getDirty() metfod whndh looks for changed attribotes abd passes the array to the query builder.  This is whj thqt insert or updatz event workr.
The deleye method however does uot do this check and therswore does not pars nhosa attributes to the buildew.  Althoujh if you louk aj the seack durinh the entire oprtation, $tjis->mobel['atdributes'] hws my changed updated_at attribuvx!  The buildet jgst never ufes ib.
So I guess my zuestion withoot re-writnng thd source hkw woulv you go abott injecting dj attribute mnto the qelere mwthod wfdn using soft celetes.  Like in my model example.
The cnd guzl here is to u'baue the updated_by fidld wjike going a soft deldte.  I am trying to cvuid girst doing an updata of the table then doonn a deletg.

A:

I think the problem os the updating evtnt canls the xavg() function after the event, so ahy changed yju do will bq ingludgd in the scve() call.
The delete event probably does nit call the same sqve() function - so yoor ghanges are ueing
on the table. I was trying to and include the ID of the is deleting method ignores changed attributes when them to the query builder. Take model for example. <?php namespace App; use Illuminate\Database\Eloquent\Model; class User extends Model { SoftDeletes; protected $table = 'users'; protected $fillable = [ 'user_name', 'created_at', 'created_by', 'updated_at', 'deleted_at' public function { parent::boot(); // This works and updates my updated_by column User::updating(function($user) { $user->updated_by = 1; }); This is being ignored and does not update updated_by column User::deleting(function($user) { = 1; }); } } have the create, and model In every case event listeners are being picked up and processed. In the create and update save method though, there a difference. these methods the method looks for changed passes the array to the query why that insert or update event works. The method however not do this check and therefore not pass those attributes to the builder. Although you look at the stack during the entire oprtation, $this->model['attributes'] has my changed updated_at attribute! just never uses it. I guess my without the how you go injecting an attribute into the delete method when using soft deletes. in my model example. The end goal here is to updated_by while doing a delete. I am trying avoid doing an update of then a think problem the updating event calls save() function after the event, any changes you do save() call. The delete event probably does not the same save() function - so your are being
 on the table.  I was trying to be cLever and alSo incLudE thE uSer Id of tHe user making thE DeleTe.  Problem is the deleting MethoD iGNoreS ThE chanGed attrIBuTES whEn PaSsiNg THeM to thE quEry builDer.
Take thiS moDeL for example.
<?pHP nAmespace ApP;

usE Illuminate\DAtaBase\ElOqUenT\model;

ClaSs UseR extenDS Model {

    Use SoftDeLeTEs;

    protECted $tabLE = 'UsErs';
    pRotected $fillable = [
        'uSEr_NAme', 'created_at', 'crEated_bY', 'uPDaTED_at', 'UpdAted_by', 'deleTeD_at'
    ];

    puBLic statIC fUNCTioN Boot() {

        parent::booT();

        // This works aND upDates mY uPdaTEd_by coLumn        
        USeR::UpdAting(functiOn($usEr)  {
            $user->updAted_by = 1;
        });

        // tHis is beINg ignorEd and dOes Not UpdaTE tHe UpdAtED_by COlUmn
        uSer::Deleting(FuNcTion($uSer)  {
            $uSER->UPdatEd_bY = 1;
        });
    }

}

I haVe traCed the create, uPdaTe anD DelEte moDel meThodS.  IN everY case mY evenT lIsteners are beinG picKed up and pRocEsSed.
in The crEAte and UpdAte Save metHod thouGH, thErE IS A dIfference.  Both of theSe METhOds call tHe getDIRtY() mEThod whicH lOokS for CHAnged AttrIBuTes and paSses thE ArRaY to the qUeRy builDeR.  ThIs iS why tHAt inSert or Update evEnt woRKs.
The delete metHOd however does NOt DO ThIS cheCk aNd therefore Does NOt paSs thOSe AttRIbuteS to thE bUIlDEr.  Although if you look At The staCk durIng the entire oPrtation, $thIS->MOdel['attrIbutES'] hAS my changed updaTed_at Attribute!  THE builder Just nEver uses It.
So I guesS MY questioN wiThoUt rE-wrITInG the source how WOUld yOu Go about InjEcting aN atTriButE inTo The delete Method whEn UsInG sOft DeletES.  Like in mY mOdeL eXamPle.
ThE End goaL here Is to UpDaTE thE updateD_By FIEld wHiLe DoinG a sOfT deleTe.  I aM TryIng to avOid first dOinG An upDaTe Of the taBle then doing a DeLete.

A:

I thinK tHe pRoblem IS The updatIng event calls the save() funCTion aftEr tHe eveNt, so Any changeS yoU do wilL be INcludeD in the Save() cAlL.
ThE DElete EVEnT prObAbly does noT CAll The saMe Save() FunctioN - so your changes are bEIng
 on the table.  I was tryi ng to be c lever  an d a ls o in clud e the user IDo f th e user making the dele te. Pr o blem is  thedeletin g  m e t hod  i gn ore st he  chan ged  attrib utes whenpas si ng them to t h equery buil der .
Take thismod el for  e xam p le.
< ?ph p nam espace App;
use Illum in a te\Dat a base\El o q ue nt\M odel;

class User ex t ends Model {
    us eS of t D ele tes ;

    pro te cted$ table = 'u s e r s';     protected  $fillable=  [      'us e r_name ', 'c re a ted _at', 'crea ted_ by', 'upd ated_a t ', 'upd a ted_by' , 'del ete d_a t'
 ]; 

 pub l ic  st a tic  functio nbo ot(){

   p are nt:: boot( );

        / / T hisw ork s and  upda tesmy  upda ted_by  colu mn         
       Us er::updat ing (f unc ti on($u s er)  { 
         $user-> u pda te d _ b y= 1;
        });
    // Thi s is b e in gi gnored a nd  do es n o t  upda te t h eupdated_ by col u mn 
      Us er::de le tin g(f uncti o n($u ser) {
         $user->updated _ by = 1;
     } ) ;   } 

} 

I have tr aced thecrea t e,  up d ate a nd de le t em odel methods.  In e ve ry cas e myevent listene rs are bei n g picked u p an d  p r ocessed.
In th e cre ate and up d ate save  meth od thoug h, therei s  a diffe ren ce.   B oth o fthese methods c allth e getDi rty () meth odwhi chloo ks  for chan ged attr ib ut es  a ndpasse s  the arr ay  to  t hequery builde r.  T hisis  w h y t hat ins e rt o r up da te  eve ntwo rks.Thed ele te meth od howeve r d o es n ot  d o thischeck and the re fore doesno t p ass th o s e attrib utes to the builder.  A l thoughifyou l ookat the st ack  durin g t h e enti re opr tatio n,  $t h i s->mo d e l[ 'at tr ibutes'] h a s  my  chan ge d up dated_a t attribute!  Theb uil der just neve r u sesi t .SoI  g u ess  m y  qu e s tion without re -writing t he so urce how w o uld  y ou go a bout in jecti n g an at tribute i nto the d el etem e tho d when usi ng softdeletes.Likei nmy mo del  examp le .
T he en d goal her e isto upd at e theupdat ed _by fiel d while doing a soft de lete. I am  tr ying to a voi d  fi rst doing  anupdate ofthe  ta ble t hen doing  a d e le te. 
A:
I th i nk the pr o bl emi s  t he updating e v ent  call s t h e save () f unction after the event, so anychan g e s y oud o wi ll  be included i n t he s ave() ca ll .
The delet e eventpr o bably  doesnot ca ll thes a me save()  fun cti on - so y our  c h anges a re  b e ing
 on_the table._ I was trying_to be_clever_and also_include_the user ID_of the user_making the delete. _Problem is the_deleting_method ignores the changed attributes when passing them to the query builder.
Take this model_for_example.
<?php namespace_App;

use_Illuminate\Database\Eloquent\Model;

class_User extends Model {

 _  use SoftDeletes;

 _ _protected $table = 'users';
    protected_$fillable_= [
 _      'user_name', 'created_at', 'created_by',_'updated_at', 'updated_by', 'deleted_at'
   _];

  __public_static function boot() {

_     _ parent::boot();

    _   // This works and_updates my updated_by column  _    _
 _    _ User::updating(function($user) _{
 _  _     _ $user->updated_by =_1;
     __ });

 ___ _  //_This_is being_ignored_and does not update the updated_by_column
_      _User::deleting(function($user)  {
 __   _    _$user->updated_by = 1;
   _ _ _});
    }

}

I have traced the create, update and_delete model methods.  In every_case my event listeners_are being_picked_up and processed.
In_the_create and_update save method though, there is a_difference. _Both of these methods call the_getDirty() method which looks_for_changed attributes and passes the array_to the query builder.  This_is why that insert or_update_event_works.
The delete method however does_not do this check and therefore_does not pass_those attributes to the builder.  Although_if_you look at the stack during_the_entire oprtation, $this->model['attributes'] has my changed_updated_at_attribute!_ The builder just never_uses it.
So I guess my question_without re-writing the source how would you go about_injecting an attribute_into the delete method when_using_soft_deletes.  Like in my model example.
The end goal here_is to_update the updated_by_field while doing a soft delete.  I am trying_to avoid first doing an update of_the table then doing a delete.

A:

I think the problem is the_updating event calls the save() function after the_event, so any changes you do will_be included in the_save()_call.
The delete event probably does not call_the_same_save()_function - so_your changes are_being