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
const Logger = use('Logger'); | |
class RoleDetector { | |
async handle ({ auth, request }, next, props) { | |
Logger.info('RoleDetector. Role: %s', props); | |
await next(); | |
} | |
} |
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
const Schema = use('Schema'); | |
class UserSchema extends Schema { | |
async up () { | |
const exists = await this.hasTable('users); | |
if (!exists) { | |
this.createTable('users', (table) => { | |
table.increments('id'); | |
table.string('email', 254) |
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
const Schema = use('Schema'); | |
class ProfileSchema extends Schema { | |
async up () { | |
const exists = await this.hasTable('profiles'); | |
if (!exists) { | |
this.createTable('profiles', (table) => { | |
table.increments('id'); | |
table.integer('user_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
const Factory = use('Factory'); | |
const User = use('App/Models/User'); | |
const Logger = use('Logger'); | |
class UserSeeder { | |
async run () { | |
const ADMIN_USER_EMAIL = 'admin@gmail.com'; | |
const isPresent = await User.findBy('email', ADMIN_USER_EMAIL); | |
// if user was not previously added in database | |
if (!isPresent) { |
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
const Factory = use('Factory'); | |
const Logger = use('Logger'); | |
Factory.blueprint('App/Models/User', async (faker) => { | |
const email = faker.email(); | |
const password = faker.password(); | |
const role = 'USER'; | |
Logger | |
.transport('file') |
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
const Factory = use('Factory'); | |
const User = use('App/Models/User'); | |
const Logger = use('Logger'); | |
/** | |
* This will help us to create 10 users with 10 Profiles, using async in array | |
* https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Statements/for-await...of | |
* @type {{[Symbol.asyncIterator](): {next(): (Promise<{value, done: boolean}>), i: number}}} | |
*/ | |
const asyncIterable = { |
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
logger: { | |
transport: 'console', | |
console: { | |
driver: 'console', | |
name: 'adonis-app', | |
level: 'debug', | |
}, | |
file: { | |
driver: 'file', | |
name: 'adonis-app', |
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
class PlayerButton extends StatefulWidget { | |
final VoidCallback onPressed; | |
final bool isTrue; | |
final String trueText; | |
final String falseText; | |
PlayerButton({ | |
@required this.onPressed, | |
@required this.isTrue, | |
@required this.trueText, |
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
import 'package:flutter/material.dart'; | |
class Multibar extends StatefulWidget { | |
@override | |
_MultibarState createState() => _MultibarState(); | |
} | |
class _MultibarState extends State<Multibar> | |
with SingleTickerProviderStateMixin { | |
AnimationController animationController; |
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
import 'package:flutter/material.dart'; | |
class TransformExamples extends StatefulWidget { | |
@override | |
_TransformExamplesState createState() => _TransformExamplesState(); | |
} | |
class _TransformExamplesState extends State<TransformExamples> | |
with SingleTickerProviderStateMixin { | |
AnimationController animationController; |