diff --git a/app/Contact.php b/app/Contact.php new file mode 100644 index 0000000..599eb88 --- /dev/null +++ b/app/Contact.php @@ -0,0 +1,10 @@ +$contact + + ]; + return response()->json($contact, 200); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $contact = Contact::create($request->all()); + + return response()->json($contact, 201); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { +// $contact = Contact::find($id); +// if (!$contact) +// { +// return response()->json(['message'=>'ID not found'],200); +// +// } +// +// $contact->ff_id=$request->input('ff_id'); +// +// +// $contact->save(); +// return response()->json(['contact'=>$contact],200); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + $contact=Contact::find($id); + $contact->delete(); + + return response()->json($contact, 204); + } +} diff --git a/database/migrations/2018_04_30_082838_create_contacts_table.php b/database/migrations/2018_04_30_082838_create_contacts_table.php new file mode 100644 index 0000000..8409379 --- /dev/null +++ b/database/migrations/2018_04_30_082838_create_contacts_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('ff_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('contacts'); + } +} diff --git a/routes/api.php b/routes/api.php index a1ede1b..40aad41 100644 --- a/routes/api.php +++ b/routes/api.php @@ -32,3 +32,8 @@ Route :: post('/warehouse','WarehouseController@store'); Route :: get('/warehouse/{war_id}','WarehouseController@show'); Route :: put('/warehouse/{war_id}','WarehouseController@update'); Route :: get('/warehouse','WarehouseController@index'); + + +Route :: delete('/contacts/{ff_id}','ContactController@destroy'); +Route :: get('/contacts','ContactController@index'); +Route :: post('/contacts','ContactController@store'); \ No newline at end of file