Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestPullRequest マージ禁止 #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions src/Controller/UsersController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
namespace App\Controller;

use App\Controller\AppController;

/**
* Users Controller
*
* @property \App\Model\Table\UsersTable $Users
*/
class UsersController extends AppController
{

/**
* Index method
*
* @return void
*/
public function index()
{
$this->set('users', $this->paginate($this->Users));
$this->set('_serialize', ['users']);
}

/**
* View method
*
* @param string|null $id User id.
* @return void
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function view($id = null)
{
$user = $this->Users->get($id, [
'contain' => []
]);
$this->set('user', $user);
$this->set('_serialize', ['user']);
}

/**
* Add method
*
* @return void Redirects on successful add, renders view otherwise.
*/
public function add()
{
$user = $this->Users->newEntity();
if ($this->request->is('post')) {
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
$this->Flash->success(__('The user has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The user could not be saved. Please, try again.'));
}
}
$this->set(compact('user'));
$this->set('_serialize', ['user']);
}

/**
* Edit method
*
* @param string|null $id User id.
* @return void Redirects on successful edit, renders view otherwise.
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function edit($id = null)
{
$user = $this->Users->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
$this->Flash->success(__('The user has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The user could not be saved. Please, try again.'));
}
}
$this->set(compact('user'));
$this->set('_serialize', ['user']);
}

/**
* Delete method
*
* @param string|null $id User id.
* @return void Redirects to index.
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$user = $this->Users->get($id);
if ($this->Users->delete($user)) {
$this->Flash->success(__('The user has been deleted.'));
} else {
$this->Flash->error(__('The user could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}
24 changes: 24 additions & 0 deletions src/Model/Entity/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
namespace App\Model\Entity;

use Cake\ORM\Entity;

/**
* User Entity.
*/
class User extends Entity
{

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
* Note that '*' is set to true, which allows all unspecified fields to be
* mass assigned. For security purposes, it is advised to set '*' to false
* (or remove), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'*' => true,
'id' => false,
];
}
74 changes: 74 additions & 0 deletions src/Model/Table/UsersTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
namespace App\Model\Table;

use App\Model\Entity\User;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;

/**
* Users Model
*
*/
class UsersTable extends Table
{

/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);

$this->table('users');
$this->displayField('name');
$this->primaryKey('id');

}

/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->add('id', 'valid', ['rule' => 'numeric'])
->allowEmpty('id', 'create');

$validator
->requirePresence('name', 'create')
->notEmpty('name');

$validator
->requirePresence('uid', 'create')
->notEmpty('uid');

$validator
->requirePresence('nickname', 'create')
->notEmpty('nickname');

$validator
->requirePresence('avator', 'create')
->notEmpty('avator');

$validator
->requirePresence('access_token', 'create')
->notEmpty('access_token');

$validator
->requirePresence('created_at', 'create')
->notEmpty('created_at');

$validator
->allowEmpty('updated_at');

return $validator;
}
}
23 changes: 23 additions & 0 deletions src/Template/Users/add.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="actions columns large-2 medium-3">
<h3><?= __('Actions') ?></h3>
<ul class="side-nav">
<li><?= $this->Html->link(__('List Users'), ['action' => 'index']) ?></li>
</ul>
</div>
<div class="users form large-10 medium-9 columns">
<?= $this->Form->create($user) ?>
<fieldset>
<legend><?= __('Add User') ?></legend>
<?php
echo $this->Form->input('name');
echo $this->Form->input('uid');
echo $this->Form->input('nickname');
echo $this->Form->input('avator');
echo $this->Form->input('access_token');
echo $this->Form->input('created_at');
echo $this->Form->input('updated_at');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
29 changes: 29 additions & 0 deletions src/Template/Users/edit.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div class="actions columns large-2 medium-3">
<h3><?= __('Actions') ?></h3>
<ul class="side-nav">
<li><?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $user->id],
['confirm' => __('Are you sure you want to delete # {0}?', $user->id)]
)
?></li>
<li><?= $this->Html->link(__('List Users'), ['action' => 'index']) ?></li>
</ul>
</div>
<div class="users form large-10 medium-9 columns">
<?= $this->Form->create($user) ?>
<fieldset>
<legend><?= __('Edit User') ?></legend>
<?php
echo $this->Form->input('name');
echo $this->Form->input('uid');
echo $this->Form->input('nickname');
echo $this->Form->input('avator');
echo $this->Form->input('access_token');
echo $this->Form->input('created_at');
echo $this->Form->input('updated_at');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
49 changes: 49 additions & 0 deletions src/Template/Users/index.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<div class="actions columns large-2 medium-3">
<h3><?= __('Actions') ?></h3>
<ul class="side-nav">
<li><?= $this->Html->link(__('New User'), ['action' => 'add']) ?></li>
</ul>
</div>
<div class="users index large-10 medium-9 columns">
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th><?= $this->Paginator->sort('id') ?></th>
<th><?= $this->Paginator->sort('name') ?></th>
<th><?= $this->Paginator->sort('uid') ?></th>
<th><?= $this->Paginator->sort('nickname') ?></th>
<th><?= $this->Paginator->sort('avator') ?></th>
<th><?= $this->Paginator->sort('access_token') ?></th>
<th><?= $this->Paginator->sort('created_at') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($users as $user): ?>
<tr>
<td><?= $this->Number->format($user->id) ?></td>
<td><?= h($user->name) ?></td>
<td><?= h($user->uid) ?></td>
<td><?= h($user->nickname) ?></td>
<td><?= h($user->avator) ?></td>
<td><?= h($user->access_token) ?></td>
<td><?= h($user->created_at) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $user->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $user->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $user->id], ['confirm' => __('Are you sure you want to delete # {0}?', $user->id)]) ?>
</td>
</tr>

<?php endforeach; ?>
</tbody>
</table>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->prev('< ' . __('previous')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('next') . ' >') ?>
</ul>
<p><?= $this->Paginator->counter() ?></p>
</div>
</div>
36 changes: 36 additions & 0 deletions src/Template/Users/view.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class="actions columns large-2 medium-3">
<h3><?= __('Actions') ?></h3>
<ul class="side-nav">
<li><?= $this->Html->link(__('Edit User'), ['action' => 'edit', $user->id]) ?> </li>
<li><?= $this->Form->postLink(__('Delete User'), ['action' => 'delete', $user->id], ['confirm' => __('Are you sure you want to delete # {0}?', $user->id)]) ?> </li>
<li><?= $this->Html->link(__('List Users'), ['action' => 'index']) ?> </li>
<li><?= $this->Html->link(__('New User'), ['action' => 'add']) ?> </li>
</ul>
</div>
<div class="users view large-10 medium-9 columns">
<h2><?= h($user->name) ?></h2>
<div class="row">
<div class="large-5 columns strings">
<h6 class="subheader"><?= __('Name') ?></h6>
<p><?= h($user->name) ?></p>
<h6 class="subheader"><?= __('Uid') ?></h6>
<p><?= h($user->uid) ?></p>
<h6 class="subheader"><?= __('Nickname') ?></h6>
<p><?= h($user->nickname) ?></p>
<h6 class="subheader"><?= __('Avator') ?></h6>
<p><?= h($user->avator) ?></p>
<h6 class="subheader"><?= __('Access Token') ?></h6>
<p><?= h($user->access_token) ?></p>
</div>
<div class="large-2 columns numbers end">
<h6 class="subheader"><?= __('Id') ?></h6>
<p><?= $this->Number->format($user->id) ?></p>
</div>
<div class="large-2 columns dates end">
<h6 class="subheader"><?= __('Created At') ?></h6>
<p><?= h($user->created_at) ?></p>
<h6 class="subheader"><?= __('Updated At') ?></h6>
<p><?= h($user->updated_at) ?></p>
</div>
</div>
</div>
Loading