Basically I manage to get my soft delete working on my User table., problem is now my other pages would not work, I believe I need to make some changes using the withTrashed to the queries for the pages? For example the controller as shown below, how do I add the users column which have been soft deleted, can someone guide me and help me with this?
Controller.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Zone;
use App\Parameter;
class DashboardController extends Controller
{
    public function index() {
        $zones = Zone::all();
        $parameters = Parameter::all();
        return view('dashboard', compact('zones', 'parameters'));
    }
}
You can just add ->withTrashed() to your query and use get instead of all. Like so:
$zones = Zone::all(); //Excludes soft deleted
$allparameters = Parameter::withTrashed()->get(); //Includes soft deleted
$allusers = User::withTrashed()->get();
Also, onlyTrashed() will do what it suggests:
$trashedusers = User::onlyTrashed()->get(); //Only soft deleted users
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With