Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use App\Author;
- use App\Http\Requests\AuthorStoreRequest;
- use Illuminate\Http\Request;
- class AuthorController extends Controller
- {
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function index()
- {
- //
- $authors = Author::all();
- $response=[
- 'message'=>'Lista de Autores',
- 'data'=>$authors,
- 'result'=>'ok'
- ];
- return response($response);
- }
- /**
- * 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(AuthorStoreRequest $request)
- {
- //
- $data=$request->all(); //array com as informações q mandar por post
- $author=Author::create($data);
- $response=[
- 'message'=>'Autor Adicionado',
- 'data'=>$author,
- 'result'=>'ok'
- ];
- return response($response);
- }
- /**
- * Display the specified resource.
- *
- * @param \App\Author $author
- * @return \Illuminate\Http\Response
- */
- public function show(Author $author)
- {
- //
- $response=[
- 'message'=>'Autor selecionado',
- 'data'=>$author,
- 'result'=>'ok'
- ];
- return response($response);
- }
- /**
- * Show the form for editing the specified resource.
- *
- * @param \App\Author $author
- * @return \Illuminate\Http\Response
- */
- public function edit(Author $author)
- {
- //
- }
- /**
- * Update the specified resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @param \App\Author $author
- * @return \Illuminate\Http\Response
- */
- public function update(AuthorStoreRequest $request, Author $author)
- {
- //
- $data=$request->all();
- $author->update($data);
- $response=[
- 'message'=>'Autor Atualizado',
- 'data'=>$author,
- 'result'=>'ok'
- ];
- return response($response);
- }
- /**
- * Remove the specified resource from storage.
- *
- * @param \App\Author $author
- * @return \Illuminate\Http\Response
- */
- public function destroy(Author $author)
- {
- //
- $author->delete();
- $response=[
- 'message'=>'Autor Apagado',
- 'data'=>$author,
- 'result'=>'ok'
- ];
- return response($response);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement