本文整理汇总了PHP中Home::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Home::create方法的具体用法?PHP Home::create怎么用?PHP Home::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Home
的用法示例。
在下文中一共展示了Home::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created home in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Home::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
Home::create($data);
return Redirect::route('homes.index');
}
示例2: Validate
use Environment\Core\Validate;
use Environment\Helpers\Html;
use Environment\Helpers\Link;
use Environment\Helpers\Form;
use Environment\Helpers\Date;
use Environment\Helpers\String;
App::setTitle('Add user');
Input::find('user.login');
if (Input::isSubmit()) {
// echo Input::find('username');
$check = new Validate();
$validates_result = $check->validates($_POST['user'], ['login' => ['presence' => true, 'length' => ['minimum' => 3, 'maximum' => 50], 'uniqueness' => 'users'], 'password' => ['presence' => true, 'length' => ['minimum' => 3], 'confirmation' => true]]);
if ($validates_result->isValid()) {
$user = new Home();
try {
$user->create(['login' => Input::find('login'), 'email' => Input::find('email'), 'password' => Input::find('password'), 'group_id' => 1]);
Redirect::to(['controller' => 'home', 'action' => 'index', 'params' => []]);
} catch (Exception $e) {
die($e->getMessage);
}
} else {
echo '<div class="errors">';
foreach ($validates_result->errors() as $error) {
echo $error . '</br>';
}
echo '</div>';
}
}
?>
<form action="" method="post">
示例3: function
// return 'Middleware should be first palce';
// });
$route->respond('GET', '/', function () use($home) {
return $home->index();
});
$route->respond('GET', '/test', function () use($user, $role) {
$users = $user->all();
foreach ($users as $user) {
var_dump($user->role->permission);
}
});
$route->respond('GET', '/show/[i:id]', function ($request) use($home) {
return $home->show($request);
});
$route->respond('GET', '/create', function () use($home) {
return $home->create();
});
$route->respond('POST', '/store', function ($request, $response) use($home) {
return $home->store($request, $response);
});
$route->respond('GET', '/login', function () use($home) {
echo $home->getLogin();
unset($_SESSION['flash']);
});
$route->respond('POST', '/login', function ($request, $response, $service) use($home) {
return $home->postLogin($request, $response, $service);
});
$route->respond('GET', '/logout', function ($request, $response, $service) use($home) {
return $home->logout($request, $response, $service);
});
$route->respond('GET', '/dashboard/index', function ($request, $response) use($dashboard) {