Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with Laravel 7 #114

Closed
atix9000 opened this issue May 5, 2020 · 3 comments
Closed

Not working with Laravel 7 #114

atix9000 opened this issue May 5, 2020 · 3 comments

Comments

@atix9000
Copy link

atix9000 commented May 5, 2020

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');
        });
@renjithspace
Copy link

renjithspace commented Jun 27, 2020

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.

@maguilar92
Copy link
Collaborator

@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.

@maguilar92
Copy link
Collaborator

It's fixed on version 7.0.1 of the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants