Inicio » Cursos » Flutter App Copa América

Generar JSON con Laravel | Curso Flutter App Copa América

Desarrollo de una API Rest Básica con el Framework Laravel generando una salida de datos en formado JSON

Lección 2: Generar JSON con Laravel

El objetivo de ésta lección es generar JSON  a partir de una base de datos; para lograr ello debemos realizar los siguientes pasos:

INSTALACIÓN DE LARAVEL

CREACIÓN Y CONFIGURACIÓN BASE DE DATOS

MODELOS y MIGRACIONES EN LARAVEL

Modelo Noticias

 protected $table = "noticias";
    protected $fillable = [        
        'titulo', 
        'descripcion',
        'urlfoto',        
        'visitas',
    ];

Migración Noticias

Schema::create('noticias', function (Blueprint $table) {
            $table->increments('id');
            $table->string('titulo')->unique();
            $table->text('descripcion');
            $table->string('urlfoto')->default("foto.jpg");
            $table->integer('visitas');
            $table->timestamps();
        });

Modelo Equipos:

protected $table = "equipos";
    public $timestamps = false;
	protected $fillable =[		
		'nombre',
		'descripcion',		
		'urlfoto', 		
        'visitas',
		'votos',
		'pj',
		'pg',
		'pe',
		'pp',
		'gf',
        'gc',
        'gd',
		'pts',		
		'grupo'
	];

Migración Equipos:

Schema::create('equipos', function (Blueprint $table) {
            $table->increments('id');
            $table->string('nombre')->unique();
            $table->text('descripcion')->nullable();          
            $table->string('urlfoto')->default("foto.jpg");            
            $table->integer('votos')->default(1);
            $table->integer('pj')->nullable();
            $table->integer('pg')->nullable();
            $table->integer('pe')->nullable();
            $table->integer('pp')->nullable();
            $table->integer('gf')->nullable();
            $table->integer('gc')->nullable();
            $table->integer('pts')->nullable();
            $table->integer('gd')->nullable();
            $table->string('grupo')->nullable();            
        });

Modelo Calendarios

    protected $table = "calendarios";
	protected $fillable =[
        'fecha',
        'mes',
        'dia',
        'hora',
		'equipo_a',
        'urllogo_a',
        'equipo_b',
        'urllogo_b',        
        'descripcion',
        'orden'];

Migración Calendarios

     Schema::create('calendarios', function (Blueprint $table) {
            $table->increments('id');
            $table->string('fecha');
            $table->string('mes');
            $table->string('dia');
            $table->string('hora');
            $table->string('equipo_a');
            $table->string('urllogo_a');
            $table->string('equipo_b');
            $table->string('urllogo_b'); 
            $table->string('descripcion');
            $table->integer('orden');            
        });

 


3648 visitas

Curso Flutter App Copa América

Curso Flutter App Copa América

Descarga el código fuente del proyecto

GRATIS 0.00


COMPRAR CURSO

Codea App
Codea App FullStack

Perú, México, Colombia, España, Venezuela, Argentina, Bolivia

You Fb Tik Pin

© Todos los derechos reservados Codea App | Cursos de programación | 2020 - 2022