In my method update() has some block of error conditions Call to a member function failed on array precisely that checks if $validations fails. I noticed that all the store() and updated() methods work correctly without the need for the conditional block. I just thought it would be nice to insert these conditions.
namespace App\Http\Controllers;
use App\Http\Requests\HunterRequest;
use Illuminate\Http\Request;
use App\Models\HunterModel;
class HunterController extends Controller {
public function store(Request $request)
{
$validations = $request->validate();
if ($validations->fails()){
return redirect()->back();
}
HunterModel::create($validations);
return redirect()->to('/');
}
public function update(Request $request, $id)
{
$validations = $request->validate();
if ($validations->fails()){ // Call to a member function fails() on array
return redirect()->back();
}
HunterModel::where('id',$id)->update($validations);
return redirect()->to('/');
}
}