PHP Classes

File: app/Http/Controllers/PokemonController.php

Recommend this page to a friend!
  Classes of Renato Lucena   PHP Pokemon Script   app/Http/Controllers/PokemonController.php   Download  
File: app/Http/Controllers/PokemonController.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Pokemon Script
Provides an API to manage a database of Pokemons
Author: By
Last change:
Date: 6 years ago
Size: 967 bytes
 

Contents

Class file image Download
<?php

namespace App\Http\Controllers;

use
App\User;
use
Illuminate\Http\Request as Request;
use
App\Pokemon as Pokemon;
class
PokemonController extends Controller
{
    protected
$pokemon;
    public function
__construct( )
    {
       
$this->pokemon = new Pokemon();
    }


    public function
getIndex(){

       
$pokemon = $this->pokemon->all();
        return
view("pokemon.index",$pokemon);
    }
    public function
post( Request $request ){
       
$request = $request->all();
       
$pokemon = $this->pokemon->fill($request)->save();
        return [
"sucess"=> true , "message" =>"Inclusao realiza com sucesso"];

    }

    public function
put( Request $request ){
       
$pokemon = $this->pokemon;
       
$request = $request->fill();
        return
"put";
    }

    public function
delete( Request $id ){
       
$pokemon = $this->pokemon;
       
$pokemon->delete($id);
        return [
"success"=>true,message=>"excluido com suceso"];
    }
}