public function allow($project_id) { $key = Visitor::where("project_id", $project_id)->get()->first(); try { if ($key == null) { $key = static::random(15); Visitor::create(["project_id" => $project_id, "Key" => $key]); } } catch (\Illuminate\Database\QueryException $e) { } return redirect()->action("VisitorController@show", [$project_id]); }