本文整理匯總了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) {