Class Carbon\Carbon not found

后端 未结 8 1302
无人及你
无人及你 2020-12-24 12:17

I recently added a package to my Laravel 4 site and now anything that uses Eloquent (or at least Eloquent with any reference to date/time) is showing a 500 error that states

8条回答
  •  借酒劲吻你
    2020-12-24 12:50

    Yes, it can work as @oli-folkerd 's answer. However, as seen in Laracasts (Laravel 5 Fundamentals series Video 10 "forms" min 16:55), almost in top of your ControllerClass php file, just add the following (or import the class if your php editor allows you do so):

    use Carbon\Carbon;
    

    Now you can simply use Carbon

    $input['published_at'] = Carbon::now();
    

    without having to add Carbon\

提交回复
热议问题