laravel-5.2

How to get login with different database table column name in Laravel 5.2?

佐手、 提交于 2019-11-30 02:26:31
I have to implement login functionality in Laravel 5.2. I have successfully done so using the official Laravel documentation except that I do not know how to authenticate the user using different database table column names, namely st_username and st_password . I have searched the Internet for clues but to no avail. I don't know which class I need to use (like, use Illuminate.......) for Auth. If any one knows the answer, please let me know. Here is my code: Login View @extends('layouts.app') @section('content') <div class="contact-bg2"> <div class="container"> <div class="booking"> <h3>Login<

What is different between save(), create() function in laravel 5

我只是一个虾纸丫 提交于 2019-11-30 02:00:22
I need to know what is the difference of save() and create() function in laravel 5. Where we can use save() and create() ? Tony Vincent Model::create is a simple wrapper around $model = new MyModel(); $model->save() See the implementation /** * Save a new model and return the instance. * * @param array $attributes * @return static */ public static function create(array $attributes = []) { $model = new static($attributes); $model->save(); return $model; } save() save() method is used both for saving new model, and updating existing one. here you are creating new model or find existing one,

Manually register a user in Laravel

一世执手 提交于 2019-11-29 22:52:10
Is it possible to manually register a user (with artisan?) rather than via the auth registration page? I only need a handful of user accounts and wondered if there's a way to create these without having to set up the registration controllers and views. Christoffer Tyrefors I think you want to do this once-off, so there is no need for something fancy like creating an Artisan command etc. I would suggest to simply use php artisan tinker (great tool!) and add the following commands per user: $user = new App\User(); $user->password = Hash::make('the-password-of-choice'); $user->email = 'the-email

Please provide a valid cache path

断了今生、忘了曾经 提交于 2019-11-29 19:29:21
I duplicated a working laravel app and renamed it to use for another app. I deleted the vendor folder and run the following commands again: composer self-update composer-update npm install bower install I configured my routes and everything properly however now when I try to run my app in my browser I get the following errors: InvalidArgumentException in Compiler.php line 36: Please provide a valid cache path. ErrorException in Filesystem.php line 111: file_put_contents(F:\www\example\app\storage\framework/sessions/edf262ee7a2084a923bb967b938f54cb19f6b37d): failed to open stream: No such file

laravel 5 : Class 'input' not found

北战南征 提交于 2019-11-29 19:15:00
In my routes.php file I have : Route::get('/', function () { return view('login'); }); Route::get('/index', function(){ return view('index'); }); Route::get('/register', function(){ return view('register'); }); Route::post('/register',function(){ $user = new \App\User; $user->username = input::get('username'); $user->email = input::get('email'); $user->password = Hash::make(input::get('username')); $user->designation = input::get('designation'); $user->save(); }); I have a form for users registration. I am also taking the form inputs value in the routes.php . But the error comes up when I

Laravel 5.2, auth::check return true after login but false after redirect

不想你离开。 提交于 2019-11-29 17:21:10
I'm trying to use the authentication system that comes built in with laravel 5.2. The login seems to be working correctly, if I replace the return statement with Auth::check(), it returns true. But when I redirect to '/', Auth::check() suddenly returns false in my Auth middleware. Sessions Create method: public function create(Request $request) { $email = $request->email; $password = $request->password; if(Auth::attempt(['email' => $email, 'password' => $password])) { return redirect()->intended('/'); // returns true when replaced with Auth::check(); } return redirect("login"); } Auth

Laravel Commands, Pthreads and Closure

ε祈祈猫儿з 提交于 2019-11-29 17:16:23
There is a need to perform a specific process multiple threads. I learned about the extension for php - pthreads. For example, a simple script outside Laravel works fine and I liked the results. I decided to move in Laravel, and faced with the problem. Of course I searched in google, found some questions on stackoverflow, where replied the author of extension. But me did not help his answers, so I ask you to help me. Answered Question extension author. There is a class App\Commands\QuestionsParserCommand. Inside I created an instance of the class App\My\Questions\QuestionsParser and call the

phpunit test returns 302 for bad validation, why not 422

安稳与你 提交于 2019-11-29 17:09:42
问题 I have a request class that fails for a post request. When I call it with ajax I get an 422 because the validation rules failed. But when I use phpunit for test for the same route with same values, it returns a 302. I also get no error messages like "field foobar is required" just the 302. So how can I get the error messages to check if they are equals or not? Here is my testcode: //post exam $this->post('modul/foo/exam', [ 'date' => '2016-01-01' ]) ->assertResponseStatus(200); //post exam

Laravel 5.2 frequently logging out

China☆狼群 提交于 2019-11-29 16:58:42
I am using Laravel 5.2. with session driver set to FILE in .env file. I am logging out of the system about every 2 hours, especially when I return from PayPal payment page to my website. Can anyone help me with this? set your config settings of timeout from 120 to 2400. this is in minutes. in config/session.php 'lifetime' => 120 // This is in minutes You can find session configuration in config/session.php file. Change lifetime parameter value. You may specify the number of minutes that you wish the session to be allowed to remain idle before it expires. 'lifetime' => 120 // This is in minutes

How to use Traits - Laravel 5.2

久未见 提交于 2019-11-29 16:02:05
问题 I'm new to Traits, but I have a lot of code that is repeating in my functions, and I want to use Traits to make the code less messy. I have made a Traits directory in my Http directory with a Trait called BrandsTrait.php . And all it does is call on all Brands. But when I try to call BrandsTrait in my Products Controller, like this: use App\Http\Traits\BrandsTrait; class ProductsController extends Controller { use BrandsTrait; public function addProduct() { //$brands = Brand::all(); $brands =