PHP code example of jwohlfert23 / laravel-sync-relations
1. Go to this page and download the library: Download jwohlfert23/laravel-sync-relations library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jwohlfert23 / laravel-sync-relations example snippets
use Jwohlfert23/LaravelSyncRelations/SyncableTrait;
...
class Post extends Model {
use SyncableTrait;
}
public function update($id) {
$post = Post::find($id);
$post->saveAndSync(request()->input(), ['tags']);
}
Post::find($id)->tags->pluck('name')
["My First Tag", "My Second Tag"]