laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Made java like documentation with sample code #2437

Open thegarlynch opened 3 years ago

thegarlynch commented 3 years ago

literally there is no use of comment now other than typehinting and it is hard to watch the development of this framework. just today when i look at documentation i can see new argument $joinings in createMany of BelongsToMany. i can't see the documentation anywhere on internet nor can i see it on official documentation

     /**
     * Create an array of new instances of the related models.
     *
     * @param  iterable  $records
     * @param  array  $joinings  <- what is this ??
     * @return array
     */
    public function createMany(iterable $records, array $joinings = [])
    {
    }
akbarjimi commented 3 years ago

literally there is no use of comment now other than typehinting and it is hard to watch the development of this framework. just today when i look at documentation i can see new argument $joinings in createMany of BelongsToMany. i can't see the documentation anywhere on internet nor can i see it on official documentation

     /**
     * Create an array of new instances of the related models.
     *
     * @param  iterable  $records
     * @param  array  $joinings  <- what is this ??
     * @return array
     */
    public function createMany(iterable $records, array $joinings = [])
    {
    }

as documention said

Once we save the related model, we need to attach it to the base model via through intermediate table so we'll use the existing "attach" method to accomplish this which will insert the record and any more attributes.

$joining is a set of values that sit beside the keys in pivot table

for example : user_id, business_id, level, salary

level and salary is $joining

thegarlynch commented 3 years ago

Will it cost php performance for laravel comment to be a bit long ? aside from that i can't understand why this kind of documentation is prevalence here.

paras-malhotra commented 3 years ago

PHP is not the best language for documenting meanings of the variables because the meanings can change. For instance, where($column, $operator, $value) can sometimes become where($column, $value) with $operator being = implicitly. So then, the second argument - is it operator or value? lol. The best way is to read the docs.

The example above isn't an anomaly. It's everywhere - query builder, middleware, collections, etc.

thegarlynch commented 3 years ago

Why not made documentation aboutt the overload ? it is not that hard. just include a sample for each one

julienbourdeau commented 3 years ago

it is not that hard. just include a sample for each one

It's not that hard to do it for this one method you're interested in. Doing it across the framework is a colossal task.

thegarlynch commented 3 years ago

step by step. make it better as soon as you find it. i would help. but i don't yen know that is even in laravel spec