How can i make a query to return me the most recent added objects
Controller :
public function __construct()
{
$this->middleware(['auth', 'verified']);
}
public function index(Request $request){
$object = Obj::with('children.objectable', 'ancestorsAndSelf.objectable')->ForTheCurrentTeam()->where(
'uuid', $request->get('uuid', Obj::ForTheCurrentTeam()->whereNull('parent_id')->first()->uuid)
)
->firstOrFail();
return view('home', [
'object' => $object,
'ancestors' => $object->ancestorsAndSelf()->breadthFirst()->get(),
'recent' => $object->orderBy('created_at','desc')->get(),
dd($object),
]);
I am trying to make something like this but for the most recent added objects. How would i do it?