Skip to content

Commit

Permalink
Merge pull request #4 from joynalam67598/development-4
Browse files Browse the repository at this point in the history
complete crud app and add sweetalert
  • Loading branch information
joynalam67598 authored Sep 22, 2021
2 parents 9671fcb + 159ab76 commit 396d3af
Show file tree
Hide file tree
Showing 9 changed files with 453 additions and 26 deletions.
29 changes: 29 additions & 0 deletions laravelapi/app/Http/Controllers/API/StudentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,33 @@ public function index(){
"students"=>$students
]);
}

public function edit($id){
$student = Student::find($id);
return response()->json([
"status"=>200,
"student"=>$student,
]);
}
public function update(Request $request){
$studentId = $request->id;
$student = Student::find($studentId);
$student->name= $request->name;
$student->course= $request->course;
$student->email= $request->email;
$student->phone= $request->phone;
$student->update();
return response()->json([
"status"=>200,
"message"=>"Data updated Successfully",
]);
}
public function destroy($id){
$student = Student::find($id);
$student->delete();
return response()->json([
"status"=>200,
"message"=>"Data deleted Successfully",
]);
}
}
3 changes: 3 additions & 0 deletions laravelapi/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
// data send er jonno post;
Route::post("/add-student",[StudentController::class,'store']);
Route::get("/all-students",[StudentController::class,'index']);
Route::get("/edit-student/{id}",[StudentController::class,'edit']);
Route::post("/update-student",[StudentController::class,'update']);
Route::delete("/delete-student/{id}",[StudentController::class,'destroy']);



Expand Down
Loading

0 comments on commit 396d3af

Please sign in to comment.