如何通过Eloquent上的createdAt和updatedAt字段对相同数据进行两次排序

时间:2019-07-07 10:24:57

标签: laravel sorting eloquent slim

例如,认为我们有数据:

ID created_at

16 2019-07-07 12:00:00 2019-07-07 12:30:00

17 2019-07-07 14:00:00 2019-07-07 15:45:00

18 2019-07-07 15:00:00 2019-07-07 15:30:00

我要这样排序:

16 已创建

16 已更新

17 已创建

18 已创建

18 已更新

17 已更新

1 个答案:

答案 0 :(得分:0)

您可以在模型中更改名称;

示例;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnObjects : MonoBehaviour
{

    public Transform pickUp;
    public Transform[] spawnPoints;
    public float Timer = 10;
    public float Timer1 = 15;

    void Start()
    {
        if (spawnPoints.Length == 0)
        {
            Debug.LogError("No spawn points referenced.");
        }
    }

    void Update()
    {
        Debug.Log("Spawning: " + pickUp.name);
        Timer -= Time.deltaTime;
        Timer1 -= Time.deltaTime;

        if (Timer <= 0)
        {
            Transform _sp = spawnPoints[Random.Range(0, spawnPoints.Length)];
            Instantiate(pickUp, _sp.position, _sp.rotation);
            Timer = 10;

        }

        if(Timer1 <= 0)
        {
            //Destroy(pickUp);
            Timer1 = 15;
        }
    }
}