Problems with tp5 Association query

Soft deletion is defined in

tp5 model, and
in defining association

$order = Order::get(10);
$order->user //


//
public function user (){
    return $this-hasOne("user","id","user_id");
}

users queried in this way will not be displayed if the delete_time in the deleted datasheet field is not null.

how to make the association method query all data, including soft deleted data

the following way of writing doesn"t work. Or can I only write related queries by myself?

public function user (){
    return $this-hasOne("user","id","user_id")->withTrashed();
}
Jul.14,2021

try preloading queries using with closures? The one below.

/**
 * 
 */
class Order {
    public function user (){
    return $this-hasOne('user','id','user_id');
}

/**
 * 
 */
class User {

}
// user
$order = Order::get(10)->with(['user'=>function($q){$q->withTrashed();}]);
// user
$user = $order->user;
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e51e84-43720.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e51e84-43720.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?