Askedio/laravel-soft-cascade

Not working with Laravel 7

Closed this issue · 3 comments

user.php


namespace App;

use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use \Askedio\SoftCascade\Traits\SoftCascadeTrait;

class User extends Authenticatable
{
    use Notifiable, SoftDeletes, SoftCascadeTrait;

    protected $softCascade = ['offers'];

    public function offers()
    {
        return $this->hasMany('App\Offer');
    }

offer.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Offer extends Model
{
    use SoftDeletes;
}

UsersController.php

<?php

namespace App\Http\Controllers;

use App\User;

class UsersController extends Controller
{
    public function delete($id)
    {
        try {
            User::where('id', $id)->delete();
        } catch (\Exception $e) {
            return response()->json([
                'message' => $e->getMessage(),
            ], 403);
        }
    }
}

offers table

       Schema::create('offers', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id')->unsigned();
            $table->softDeletes();
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
        });

Same happening in Lumen 7.1.4 ((Laravel Components ^7.0). And I can see it working delete only and restore not working with this package: https://github.com/michaeldyrynda/laravel-cascade-soft-deletes.

@atix9000 What do you want to say with not working? Could you explain better what occurs?
@renjithspace As I say to @atix9000 explain better what is happening to you. Also comment to you that the package you pass only work with EloquentBuilder and our package also work with QueryBuilder.

@atix9000 @renjithspace You are free to submit a pull request with the fixes.

It's fixed on version 7.0.1 of the package.