PHP code example of ddzobov / laravel-pivot-softdeletes
1. Go to this page and download the library: Download ddzobov/laravel-pivot-softdeletes 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/ */
ddzobov / laravel-pivot-softdeletes example snippets
use DDZobov\PivotSoftDeletes\Model;
class Post extends Model
{
public function tags()
{
return $this->belongsToMany(Tag::class)->withSoftDeletes();
}
}
class Tag extends Model
{
public function posts()
{
return $this->belongsToMany(Post::class)->withSoftDeletes();
}
}
use DDZobov\PivotSoftDeletes\Model;
use DDZobov\PivotSoftDeletes\Relations\Pivot;
class Post extends Model
{
public function tagsWithCustomPivot()
{
return $this->belongsToMany(Tag::class)->using(PostTag::class)->withSoftDeletes();
}
}
class Tag extends Model
{
public function postsWithCustomPivot()
{
return $this->belongsToMany(Post::class)->using(PostTag::class)->withSoftDeletes();
}
}
class PostTag extends Pivot
{
}