Back

tinker parsed my error T_PAAMAYIM_NEKUDOTAYIM


I'm trying to insert data using tinker compact method

here is my tinker snippet

$post = App\Post::create(['post_title' => 'Laravel Is generate some code!' , 'post_body' => 'Laravel 5.1 Have strong and clean method to type a code using OOP and MVC techneiq' , 'post_author_id' => '1', 'post_date' => Carbon\Carbon::now()->toDateString(), 'post_time' => Carbon\Carbon::now()->toTimeString(), 'publish_date'=> Carbon\Carbon()::tomorrow()->toDateString(), 'publish_time' => '12:30:00']);

Here my Post Model

class Post extends Model
{
    //

    protected $fillable = [
        'post_title',
        'post_body',
        'post_author_id',
        'post_date',
        'post_time',
        'publish_date',
        'publish_time'
    ];


}

I got this error

....PHP Parse error: Syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting ']' on line 1

any solution (:

thomastkim replied 3 years ago Solution

It's probably this line of code:

Carbon\Carbon()::tomorrow()->toDateString()

It should be:

Carbon\Carbon::tomorrow()->toDateString()
shez1983 replied 3 years ago

also if you really split this into three new lines.. then the error would have showed on line 3 somewhat narrowing the problem area


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us