1
I have the following table in the database
public function up()
{
Schema::create('cidades', function (Blueprint $table) {
$table->increments('id');
$table->integer('uf');
$table->string('nome_uf');
$table->integer('mesorregiao_geografica');
$table->string('nome_nesorregiao');
$table->integer('microrregiao_geografica');
$table->string('nome_microrregiao');
$table->integer('municipio');
$table->integer('cod_municipio_completo');
$table->string('nome_municipio');
});
}
I’ve already created the city model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Cidade extends Model
{
//
}
already tested insert data from Tinker and worked.
use App\Cidade
$cidade= new cidade
$cidade->nome_uf= "teste";
$franqueado->save();
But now I can’t give a foreach, no view.... How do I list the names of all cities and give a foreach to appear in the view?
In fact if you’re gonna put all the fields like
$fillable
you might as well useprotected $guarded = [];
, https://laravel.com/docs/5.4/eloquent#mass-assignment– Miguel