Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User extends Authenticatable
- {
- use Notifiable, HasRoles, SoftDeletes;
- protected $guard_name = 'web';
- protected $fillable = [
- 'username', 'password'
- ];
- protected $dates = ['deleted_at'];
- }
- $a = User::all();
- dd($a);
- |id|user_id|parent_id|
- class Parent extends Model
- {
- protected $table = 'parent';
- public function user()
- {
- return $this->belongsTo('AppUser');
- }
- }
- $getParent = Parent::with('user')->get();
- public function user()
- {
- return $this->belongsTo('AppUser')->whereNull('users.deleted_at');
- }
- public function groups()
- {
- return $this
- ->belongsToMany('Group')
- ->whereNull('group_user.deleted_at') // Table `group_user` has column `deleted_at`
- ->withTimestamps(); // Table `group_user` has columns: `created_at`, `updated_at`
- }
- User::find(1)->groups()->detach();
- DB::table('group_user')
- ->where('user_id', $user_id)
- ->where('group_id', $group_id)
- ->update(array('deleted_at' => DB::raw('NOW()')));
- $trashedAndNotTrashed = Model::withTrashed()->get();
- $onlySoftDeleted = Model::onlyTrashed()->get();
Add Comment
Please, Sign In to add comment