public function seeder() { //adding new route $route = new Route(); $route->name = '/login'; $route->save(); //adding a method to route $method = $route->methods()->create(['tags' => 'customer', 'method' => 'POST', 'description' => 'Post operation on customer route']); //adding parameters to method $method->parameters()->create(['name' => 'mobile', 'in' => 'formData', 'description' => 'mobile number of customer', 'required' => true, 'type' => 'string']); $method->parameters()->create(['name' => 'password', 'in' => 'formData', 'description' => 'password of customer', 'required' => true, 'type' => 'string']); return true; }
public function addapi() { if (isset($_POST) == true && empty($_POST) == false) { $api = $_POST['api']; $methodName = $_POST['method']; $tags = $_POST['tags'] ? $_POST['tags'] : 'default'; $description = $_POST['description'] ? $_POST['description'] : ' '; $BX_NAME = $_POST['BX_NAME']; $BX_TYPE = $_POST['BX_TYPE']; $BX_CHK = $_POST['BX_CHK']; $BX_DESCRIPTION = $_POST['BX_DESCRIPTION']; $BX_IN = $_POST['BX_IN']; $param_count = count($BX_NAME); //check if route already exists $route = Route::where('name', '=', $api)->first(); if (!$route) { //adding new route $route = new Route(); $route->name = $api; $route->save(); } $method = $route->methods()->where('method', '=', $methodName)->firstOrCreate(['tags' => $tags, 'method' => $methodName, 'description' => $description]); //parameters //if blank field submitted in parameter don't add it for ($i = 0; $i < $param_count; $i++) { if ($BX_NAME[$i] != '') { $BX_CHK[$i] = 'on' ? true : false; $BX_DESCRIPTION[$i] = $BX_DESCRIPTION[$i] ? $BX_DESCRIPTION[$i] : ' '; $method->parameters()->create(['name' => $BX_NAME[$i], 'in' => $BX_IN[$i], 'description' => $BX_DESCRIPTION[$i], 'required' => $BX_CHK[$i], 'type' => $BX_TYPE[$i]]); } //END if } //for header('location: ' . URL . '/show'); } else { header('location: ' . URL . '/show'); } //if-else post }