daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Oct 17th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class User extends Authenticatable
  2. {
  3.     use Notifiable, HasRoles, SoftDeletes;
  4.     protected $guard_name = 'web';
  5.     protected $fillable = [
  6.         'username', 'password'
  7.     ];
  8.     protected $dates = ['deleted_at'];
  9.  
  10. }
  11.    
  12. $a = User::all();
  13. dd($a);
  14.    
  15. |id|user_id|parent_id|
  16.    
  17. class Parent extends Model
  18. {
  19.     protected $table = 'parent';
  20.     public function user()
  21.     {
  22.         return $this->belongsTo('AppUser');
  23.     }
  24.  
  25. }
  26.  
  27.  
  28. $getParent = Parent::with('user')->get();
  29.    
  30. public function user()
  31. {
  32.     return $this->belongsTo('AppUser')->whereNull('users.deleted_at');
  33. }
  34.    
  35. public function groups()
  36. {
  37.  
  38.     return $this
  39.     ->belongsToMany('Group')
  40.     ->whereNull('group_user.deleted_at') // Table `group_user` has column `deleted_at`
  41.     ->withTimestamps(); // Table `group_user` has columns: `created_at`, `updated_at`
  42.  
  43. }
  44.    
  45. User::find(1)->groups()->detach();
  46.    
  47. DB::table('group_user')
  48. ->where('user_id', $user_id)
  49. ->where('group_id', $group_id)
  50. ->update(array('deleted_at' => DB::raw('NOW()')));
  51.    
  52. $trashedAndNotTrashed = Model::withTrashed()->get();
  53.    
  54. $onlySoftDeleted = Model::onlyTrashed()->get();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top