This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS `regiones` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`nombre_region` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE KEY `nombre_region_unique` (`nombre_region`), | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
INSERT INTO `nombre_region` (`id`, `nombre_region`) VALUES | |
(1, 'XV Región de Arica y Parinacota'), | |
(2, 'I Región de Tarapacá'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Notifications\Notifiable; | |
use Illuminate\Foundation\Auth\User as Authenticatable; | |
class User extends Authenticatable | |
{ | |
use Notifiable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Post extends Model | |
{ | |
public function user() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Like extends Model | |
{ | |
public function user() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Comment extends Model | |
{ | |
public function user() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get('/', function () { | |
$user = App\User::find(1); // Usaremos 1 usuario para probar | |
return view('welcome')->with('user', $user); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="row"> | |
<div class="col-md-4"> | |
<h2>Usuario: {{ $user->name }}</h2> | |
</div> | |
<div class="col-md-3"> | |
<h2>Seguidores de {{ $user->name }}:</h2> | |
<ul> | |
@foreach ($user->followers as $follower) | |
<li>{{ $follower->name }}</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//... Se omiten los namespaces por brevedad | |
class CreateUsersTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::create('users', function (Blueprint $table) { | |
$table->increments('id')->unsigned(); | |
$table->string('name'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//... se omiten los namespaces por brevedad | |
class CreateFollowersTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::create('followers', function (Blueprint $table) { | |
$table->increments('id'); | |
$table->integer('follower_id')->unsigned(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
... | |
class CreatePostsTable extends Migration | |
{ | |
public function up() | |
{ | |
Schema::create('posts', function (Blueprint $table) { | |
$table->increments('id')->unsigned(); | |
$table->integer('user_id')->unsigned(); |
OlderNewer