laravel relational save and sync methods

Solutions on MaxInterview for laravel relational save and sync methods by the best coders in the world

showing results for - "laravel relational save and sync methods"
Thiago
27 Oct 2016
1 * hasOne / hasMany (1-1, 1-M)
2    -save(new or existing child)
3    -saveMany(array of models new or existing)
4    -create(array of attributes)
5    -createMany(array of arrays of attributes)
6    ---------------------------------------------------------------------------
7
8 * belongsTo (M-1, 1-1)
9    -associate(existing model)
10    ---------------------------------------------------------------------------
11
12 *  belongsToMany (M-M)
13    -save(new or existing model, array of pivot data, touch parent = true)
14    -saveMany(array of new or existing model, array of arrays with pivot ata)
15    -create(attributes, array of pivot data, touch parent = true)
16    -createMany(array of arrays of attributes, array of arrays with pivot data)
17    -attach(existing model / id, array of pivot data, touch parent = true)
18    -sync(array of ids OR ids as keys and array of pivot data as values, detach = true)
19    -updateExistingPivot(relatedId, array of pivot data, touch)
20    ---------------------------------------------------------------------------
21
22 *  morphTo (polymorphic M-1)
23    // the same as belongsTo
24    ---------------------------------------------------------------------------
25
26 *  morphOne / morphMany (polymorphic 1-M)
27    // the same as hasOne / hasMany
28    ---------------------------------------------------------------------------
29
30 *  morphedToMany /morphedByMany (polymorphic M-M)
31    // the same as belongsToMany
32
33