I have a controller method which I am using to change the status of the row data in the database. But I forget to mention status field in the model file. So the status was not changing in the database. When I added status attribute in the model file, then only I can change the status of the table data.
use AppHttpControllersController;
use AppModelsAdminServicesBundle;
class BundleController extends Controller
{
public function changeStatus($id)
{
try
{
$bundle = Bundle::find($id);
$bundle->update(['status' => false]);
return redirect()->route('admin_bundle.index');
} catch (Exception $exception)
{
return response()->json(['status'=>'error', 'error'=> $exception->getMessage()]);
}
}
}
Model file::
class Bundle extends Model
{
protected $fillable = [
'name', 'description', 'remarks', 'image_path', 'status'
];
}
I want to know that although I have kept try catch
block in my controller method but still the error was not caught in the controller. How to catch such errors like missing attributes in the model?