4

I'm using laravel since 5.1 and i've always been using Model::create method to create new DB record. Currently, i needed to dig into laravel API to find out the return type of that method (because i forgot that and also things could changed since the last time i was using Laravel framework).

So, when i was trying to find static create(..) method, i found out that the api docs for that method is missing since 5.3 version.

What is the reason of missing api docs for that method? Is it still safe to use static create method or it'll be deprecated?

Also, laravel docs missing information about nested controllers, which was in laravel 5.2 and 5.3 docs...

3
  • The create method is in the 5.3 api docs : laravel.com/api/5.3/Illuminate/Database/Eloquent/… Commented Sep 11, 2017 at 15:10
  • I believe they're asking about 5.4 and forward where there is not create method, not 5.3 and back where there is the create method. The question says it was in the 5.2 and 5.3 docs. Commented Sep 11, 2017 at 15:30
  • @Samsquanch I thought that might have been the case but I just wanted to make sure :) Commented Sep 11, 2017 at 21:07

1 Answer 1

6

From the upgrade docs for 5.4

The create & forceCreate Methods

The Model::create & Model::forceCreate methods have been moved to the Illuminate\Database\Eloquent\Builder class in order to provide better support for creating models on multiple connections. However, if you are extending these methods in your own models, you will need to modify your implementation to call the create method on the builder. For example:

public static function create(array $attributes = [])
{
    $model = static::query()->create($attributes);

    // ...

    return $model;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.