Skip to content

Commit

Permalink
Merge pull request #13 from mahfoudfx/patch-1
Browse files Browse the repository at this point in the history
Update documentation
  • Loading branch information
zareismail authored May 31, 2022
2 parents eac75d8 + b5c7cff commit 5b4bee2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ To search relation value instead of select it; you can use the `searchable` meth
## Pivots
For customizing the pivot columns when attaching a resource you can use the `pivots` method of the field. then define your custom pivot fields with the `fields` method. now, when attaching a resource; a Modal that contains the pivot fields will be displayed to you.

In addition to the pivot columns, the pivot table should have its own `id` column which must be mentioned in the model definition.

```php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
/**
* The users that belong to the role.
*/
public function users()
{
return $this->belongsToMany(User::class)->withPivot('id', 'active', 'created_by');;
}
}
```


```
use Armincms\Fields\BelongsToMany;
Expand Down

0 comments on commit 5b4bee2

Please sign in to comment.