Skip to content

Instantly share code, notes, and snippets.

Web Development with Laravel 5

目標

如何在開發的過程中加入測試。

  1. Model
  2. Repository
  3. Controller
  4. Auth
$formattedList = collect($list)
->map(function ($item) {
return $this->formatTimestamp($item, 'createDate', self::PATTERN_TIME);
})
->map(function ($item) {
return $this->formatTimestamp($item, 'activeDate', self::PATTERN_DATE);
})
->map(function ($item) {
return $this->formatNumber($item, self::ACTIVE_AMOUNT);
})
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
namespace Login.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class LoginController : ControllerBase
{
onSubmit() {
this.loading = true;
const body = () => ({
username: this.username,
password: this.password,
});
const processResponse = (response) => {
this.loading = false;
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
export default new Vuex.Store({
state: {
todos: [
{ task: 'I have a pen', done: false },
{ task: 'I have an apple', done: false },
<template>
<div id="app">
<input type="text" v-model="input"><button @click="addItem">Add</button>
<ul>
<li v-for="(item, index) in todos" @click="finishItem(index)" :key="index">
{{ item.task }}, {{ item.done }}
</li>
</ul>
<h2>Not done : {{ itemsNotDone }}</h2>
<h2>Done : {{ itemsDone }}</h2>
import Vue from 'vue';
import Vuex from 'vuex';
import axios from 'axios';
Vue.use(Vuex);
const state = {
count: 0,
todos: [],
};
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp
{
public static class MyServiceProvider
{
private static readonly Dictionary<Type, Type> Store = new Dictionary<Type, Type>();
<template>
<div id="todolist">
<input type="text" v-model="input">
<button @click="addTodo">Add</button>
<ul>
<li v-for="(item, index) in todos" @click="finishItem(index)" :key="index">
{{ item.title }}, {{ item.completed }}
</li>
</ul>
</div>
import Vue from 'vue';
import Vuex from 'vuex';
import todoApi from '../../api/todosApi';
Vue.use(Vuex);
const setTodos = (state, payload) => state.todos = payload;
const addItem = (state, payload) =>
state.todos.push({ title: payload, completed: false });