laravel-5.2

Manually register a user in Laravel

只愿长相守 提交于 2019-12-18 10:47:06
问题 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. 回答1: 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

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

廉价感情. 提交于 2019-12-18 10:46:14
问题 I need to know what is the difference of save() and create() function in laravel 5. Where we can use save() and create() ? 回答1: 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

How to clear Route Caching on server: Laravel 5.2.37

匆匆过客 提交于 2019-12-18 10:39:32
问题 This is regarding route cache on localhost About Localhost I have 2 routes in my route.php file. Both are working fine. No problem in that. I was learning route:clear and route:cache and found a small problem below. if I comment any one route in my route.php file and then run below command php artisan route:cache This will keep the route disabled because the route list is in cache now. Now, go to route.php file and try to remove commented route and then try to run that enabled url. still it

Laravel Access denied for user 'root'@'localhost' (using password: YES) in laravel 4.2

自古美人都是妖i 提交于 2019-12-18 08:27:37
问题 I have old project which built using Laravel 4.2.I am getting following error PDOException (1045) SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) I have googled and tried every think but i couldn't able to fix it .env file APP_KEY=az9tq5VHQCV9g5m2CsgY89jtijrCMgEA DB_HOST=localhost DB_DATABASE=billing DB_USERNAME=root DB_PASSWORD=1234 database.php 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'billing', 'username' => 'root',

How to run Laravel from root directory, not from public?

醉酒当歌 提交于 2019-12-18 03:49:26
问题 By default, Laravel project is run from public directory, for this I must enter URL like as: http://localhost/public/ How to configure Laravel that website will be appeared from: http://localhost/ ? 回答1: •Go to mainproject/public>> a. .htacess b. favicon.ico c. index.php d. robots.txt e. web.config 1.cut these 5 files from the public folder, and then paste on the main project folder that’s means out side of public folder… mainproject/files 2.Next after paste ,open index.php ,modify •require _

How to run Laravel from root directory, not from public?

邮差的信 提交于 2019-12-18 03:49:07
问题 By default, Laravel project is run from public directory, for this I must enter URL like as: http://localhost/public/ How to configure Laravel that website will be appeared from: http://localhost/ ? 回答1: •Go to mainproject/public>> a. .htacess b. favicon.ico c. index.php d. robots.txt e. web.config 1.cut these 5 files from the public folder, and then paste on the main project folder that’s means out side of public folder… mainproject/files 2.Next after paste ,open index.php ,modify •require _

How to resolve the error “[ErrorException] file_get_contents(/var/www/laravel/.env): failed to open stream: No such file or directory”?

流过昼夜 提交于 2019-12-18 03:04:35
问题 I'm using Ubuntu 14.04 on my machine. I installed composer and then laravel in the document root i.e. /var/www I also gave -R 777 persmission to folder laravel present in directory /var/www Then I go to directory laravel using cd /var/www/laravel and run the following command php artisan and I got to see all the available commands there. Then I typed in php artisan key:generate and got the error [ErrorException] file_get_contents(/var/www/laravel/.env): failed to open stream: No such file or

Authenticate users from more than two tables in laravel 5 [duplicate]

半腔热情 提交于 2019-12-18 01:40:47
问题 This question already has answers here : Can Anyone Explain Laravel 5.2 Multi Auth with Example (3 answers) Closed last year . As I know Auth::attempt is used to authenticate users from users table, but i want to authenticate another users from managers table and admin from admins table. I know there are laravel-multiauth plugin already exist. But can we create our own AuthServiceProvider for authenticating users from multiple tables..? 回答1: First create Admin Authenticatable in Illuminate

Has many through many-to-many

 ̄綄美尐妖づ 提交于 2019-12-17 23:38:35
问题 I have the following table layout: deals: - id - price products: - id - name deal_product: - id - deal_id - product_id metrics: - id - name metric_product: - id - metric_id - product_id - value products and metrics have a many-to-many relationship with a pivot column of value. deals and products also have a many-to-many relationship. I can get metrics for a product with $product->metrics , but I want to be able to get all metrics for all products related to a deal, so I could do something

Laravel 5.2 redirect back with success message

ⅰ亾dé卋堺 提交于 2019-12-17 22:44:14
问题 I'm trying to get a success message back to my home page on laravel. return redirect()->back()->withSuccess('IT WORKS!'); For some reason the variable $success doesn't get any value after running this code. The code I'm using to display the succes message: @if (!empty($success)) <h1>{{$success}}</h1> @endif I have added the home and newsletter page to the web middleware group in routes.php like this: Route::group(['middleware' => 'web'], function () { Route::auth(); Route::get('/', function (