'Shows only 3 most recent data

So I want to display the three most recent data from the 'berita' table. i have created a function in controller, and an error appears Call to undefined method stdClass::take()

public function index()
    {
        $data = [
            'berita' => $this->BeritaModel->allData()->last()->take(3)->get(),
        ];
        return view('user.v_home_smk', $data);
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source