laravel-5

foreach Laravel-5 <option select

孤人 提交于 2021-02-08 10:28:18
问题 I have tried a lot of variants of code and tried to find similar problem in other topics. So, i have table users where each user is having one city(stored as a number), and of course table city with id and name of city (40 cities is there). When real user open his profile settings page I want his city to be selected and and displayed in form. In this example in user table "Alex" is having city"2". In table city: id "2" and name_ru "cityB". If i try this: @foreach(App\City::get() as $city)

Laravel session data is lost after click

陌路散爱 提交于 2021-02-08 07:56:38
问题 class FileController extends Controller { public function login() { /* * TODO: Handle via CAS * Hardcoded for demo purposes */ Session::put('isLogged', true); Session::put('index', "123456"); return View::make('login'); } public function user() { if(Session::get('isLogged') == true ) return View::make('user'); } } I have the following code. There is a link on login that goes to the FileControllers@user . On the second page my session data is lost (Session::all() is empty). What could be

Laravel session data is lost after click

我与影子孤独终老i 提交于 2021-02-08 07:55:33
问题 class FileController extends Controller { public function login() { /* * TODO: Handle via CAS * Hardcoded for demo purposes */ Session::put('isLogged', true); Session::put('index', "123456"); return View::make('login'); } public function user() { if(Session::get('isLogged') == true ) return View::make('user'); } } I have the following code. There is a link on login that goes to the FileControllers@user . On the second page my session data is lost (Session::all() is empty). What could be

How to Require Package Into Laravel Project with Composer

早过忘川 提交于 2021-02-08 03:56:18
问题 I am new to Laravel and Composer, and am following some guides including LaraCasts.com . One of the things that need to be done is use Composer to require packages to use in the Laravel project. However, this doesn't work for me. I installed Laravel using the composer create-project method (http://laravel.com/docs/5.0), and so far everything was fine. However, any package I "require" now actually goes into the C:\Users\user\vendor folder, and the composer.json file is in C:\Users\user. I

Laravel sync Relation with optional parameters

那年仲夏 提交于 2021-02-08 03:39:26
问题 I use the sync function for syncing a belongsToMany Relation: $model->products()->sync($productIds); In the $productIds array there is flat array with some Id's - something like this: $productIds = [1,3,5,6]; What I want: The pivot table has also additional columns like "created_by" and "updated_by". But how can I add these fields to my array WITHOUT doing a foreach loop? Is there a shorter way to do this? I need an array like this: $productIds = [1 => [ 'created_by' => 1, 'updated_by' => 1 ]

Access to another requested input in custom rule class - Laravel

北城余情 提交于 2021-02-07 19:16:48
问题 I need to access $request->important in passes method. I need it to validate name based on this value class TestCustom implements Rule { public function passes($attribute, $value) { // } public function message() { return 'some txt'; } } Used like this: use App\Rules\TestCustom; $request->validate([ 'name' => ['required', new TestCustom], 'important' => ['required', 'string'], ]); 回答1: It's much better to pass data to rule constructor and use it inside rule afterwards. This way you can use

Laravel Password Reset Token

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-07 19:15:21
问题 Okay, this is very beginner, but I'd like an explanation. In the built-in Laravel password reset in the "postReset" method below, it specifies "token"...however, when using {!! csrf_field() !!} in the view, it generate as the input name="_token". Does the _ count as an actual character when matching up the names? Just confused how the database migration uses "token", but the csrf field sets up the input name as "_token". public function postReset(Request $request) { $this->validate($request,

Access to another requested input in custom rule class - Laravel

落爺英雄遲暮 提交于 2021-02-07 19:12:47
问题 I need to access $request->important in passes method. I need it to validate name based on this value class TestCustom implements Rule { public function passes($attribute, $value) { // } public function message() { return 'some txt'; } } Used like this: use App\Rules\TestCustom; $request->validate([ 'name' => ['required', new TestCustom], 'important' => ['required', 'string'], ]); 回答1: It's much better to pass data to rule constructor and use it inside rule afterwards. This way you can use

Laravel Password Reset Token

百般思念 提交于 2021-02-07 19:09:57
问题 Okay, this is very beginner, but I'd like an explanation. In the built-in Laravel password reset in the "postReset" method below, it specifies "token"...however, when using {!! csrf_field() !!} in the view, it generate as the input name="_token". Does the _ count as an actual character when matching up the names? Just confused how the database migration uses "token", but the csrf field sets up the input name as "_token". public function postReset(Request $request) { $this->validate($request,

LARAVEL 5 :: Display 'username' on homepage?

我的梦境 提交于 2021-02-07 14:32:18
问题 So the new version of Laravel has a login and register system already built in and so I've changed some fields in the register page and now want the 'username' to be displayed instead of the 'name' on the homepage after login. Does anyone have a clue where this is attributed? Have been searching endlessly for this. Thanks. 回答1: The file you are looking for, is the app view file. This file defines a sample basic template for your website. It is located here: resources/views/app.blade.php In