本文整理汇总了PHP中Assets::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP Assets::reset方法的具体用法?PHP Assets::reset怎么用?PHP Assets::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assets
的用法示例。
在下文中一共展示了Assets::reset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
protected function tearDown()
{
// Reset asset collections and destroy assets variable
Assets::reset();
// Delete cached file and destroy filename variable
@unlink($this->filename);
unset($this->filename);
}
示例2: startAction
/**
* Store user data and start the test
*/
public function startAction()
{
Assets::reset()->add('main');
$token = $this->getToken();
if (!$token) {
return Redirect::route('info')->with('message', 'Токен не найден');
}
$data = Input::all();
$validation = Validator::make($data, Token::$start_rules);
if (!$validation->passes()) {
return Redirect::route('start.index')->withInput()->withErrors($validation)->with('message', 'Все поля обязательны!');
}
if (!$data['department_id'] || !$data['group_id']) {
unset($data['department_id']);
unset($data['group_id']);
}
$token->update($data);
$token->start = time();
$token->status = Token::TOKEN_STATUS_STARTED;
$token->save();
return Redirect::route('test.index');
}
示例3: function
<?php
Route::pattern('id', '[0-9]+');
Route::pattern('rid', '[0-9]+');
Route::pattern('token', '[0-9a-z]+');
Route::get('/', ['as' => 'base', 'uses' => 'HomeController@defaultAction']);
Route::get('info', ['as' => 'info', 'uses' => 'HomeController@infoAction']);
/**
* Administering
*/
Route::when('admin/*', 'auth');
Route::get('admin', ['as' => 'admin', 'before' => 'auth', 'uses' => 'AdminController@defaultAction']);
Route::group(array('prefix' => 'admin'), function () {
Assets::reset()->add('admin');
});
/**
* Administering users
*/
Route::get('admin/users', ['as' => 'users.index', 'uses' => 'UserController@indexAction']);
Route::get('admin/users/create', ['as' => 'users.create', 'uses' => 'UserController@createAction']);
Route::post('admin/users', ['as' => 'users.store', 'before' => 'csrf', 'uses' => 'UserController@storeAction']);
Route::get('admin/users/{id}', ['as' => 'users.show', 'uses' => 'UserController@showAction']);
Route::get('admin/users/{id}/edit', ['as' => 'users.edit', 'uses' => 'UserController@editAction']);
Route::put('admin/users/{id}', ['as' => 'users.update', 'before' => 'csrf', 'uses' => 'UserController@updateAction']);
Route::delete('admin/users/{id}', ['as' => 'users.destroy', 'uses' => 'UserController@deleteAction']);
/**
* Authentication
*/
Route::get('/login', ['as' => 'login.get', 'uses' => 'SecurityController@loginAction']);
Route::post('/login', ['as' => 'login.post', 'before' => 'csrf', 'uses' => 'SecurityController@loginAttempt']);
Route::get('/logout', ['as' => 'logout', 'uses' => 'SecurityController@logoutAction']);
示例4: indexAction
/**
* Display question to the user
*
* @return mixed
*/
public function indexAction()
{
Assets::reset()->add('main');
$token = $this->getToken();
if (!$token) {
return Redirect::route('base');
}
if ($token->status != Token::TOKEN_STATUS_STARTED) {
return Redirect::route('token.index', ['token' => $token->token]);
}
if (!$this->isTokenValid($token)) {
Session::forget('token_string');
$token->status = Token::TOKEN_STATUS_EXPIRED;
$token->save();
return Redirect::route('info')->with('message', 'Время теста истекло');
}
/**
* get next question
*/
$questions = $token->test->questions;
$results = Result::where('token', $token->token)->where('test_id', $token->test->id)->get();
$has_questions = count($questions);
$has_results = count($results);
if (count($results)) {
if (count($results) == count($questions)) {
/**
* User have answered all questions
*/
Session::forget('token_string');
return Redirect::route('info')->with('message', 'Тест завершен. Вы ответили на все вопросы.');
} else {
/**
* Ignore answered questions
*/
$answered = [];
foreach ($results as $result) {
$answered[] = $result->question->id;
}
foreach ($questions as $key => $q) {
if (in_array($q->id, $answered)) {
unset($questions[$key]);
}
}
}
}
/**
* shuffle questions
*/
$questions_ = [];
foreach ($questions as $q) {
$questions_[] = $q->id;
}
shuffle($questions_);
if ($questionId = Session::get('question_id', false)) {
$question = Question::find($questionId);
} else {
$question = Question::find($questions_[0]);
}
$answers_ = $question->answers;
$answers = [];
Session::forget('test_answers');
$ta = [];
foreach ($answers_ as $key => $answer) {
$a = $answer->withHash();
$ta[$answer->id] = $a->hash;
$answers[] = $a;
}
Session::put('test_answers', $ta);
Session::put('question_id', $question->id);
shuffle($answers);
return View::make('test.index', ['question' => $question, 'answers' => $answers, 'token' => $token, 'total' => $has_questions, 'answered' => $has_results]);
}