@if ($loop->last)
This is the last iteration.
@endif
@if ($loop->index % 2 == 0)
Четное
@else
Нет
@endif
{{ Form::select('your_select_name', $suggestions, $youId, ['class' => 'your-select-class']) }}
public function auth()
{
// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
$this->post('logout', 'Auth\LoginController@logout')->name('logout');
// Registration Routes...
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');
// Password Reset Routes...
$this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');
}
public function getCredentials(Request $request)
{
$credentials = $request->only($this->loginUsername(), 'password');
return array_add($credentials, 'active', '1');
}
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
}
} else if (Auth::guard($guard)->user()->active == false) {
$request->session()->flush();
Auth::logout();
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect('/login');
}
}
return $next($request);
}
protected $table = 'categories';
public function posts()
{
return $this->belongsToMany('App\Models\Post', 'post_id', 'category_id);
}
protected $table = 'posts';
public function categories()
{
return $this->belongsToMany('App\Models\Category', 'post_id', 'category_id);
}
$post = Post::where('slug', $slug)->first(); -----> равенство идет по дефолту
$categories = $post->categories;
foreach ($categories as $category)
{
echo $category->id. '<br>'; -----------------> любые данные категории.
}