Skip to content

Instantly share code, notes, and snippets.

View m-alghobary's full-sized avatar
🤖
Coding

Mohamed Alghobary m-alghobary

🤖
Coding
View GitHub Profile
@m-alghobary
m-alghobary / AppServiceProvider.php
Created August 29, 2022 05:46
A Laravel macro that adds a 'sync' method to the 'HasMany' relationship similar to the one on the 'BelongsTo' relationship.
<?php
namespace App\Providers;
use Illuminate\Support\Arr;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasMany;
class AppServiceProvider extends ServiceProvider