laravel-5.2

Class '\App\User' not found in Laravel when changing the namespace

会有一股神秘感。 提交于 2019-11-29 00:39:06
问题 I am having this error when moving User.php to Models/User.php local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Class '\App\User' not found vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php:126 回答1: Go to config/auth.php and change App\User:class to App\Models\User::class. 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\Models\User::class, ], Also change the namespace of User.php model namespace App\Models; 回答2: These

Has many through many-to-many

妖精的绣舞 提交于 2019-11-28 23:26:44
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 like this: $deal->metrics . I currently have the following in my Deal model: public function metrics() {

How to add column in a table using laravel 5 migration without losing its data?

旧巷老猫 提交于 2019-11-28 22:07:41
问题 I have an existing database table and I want to add column on it. However, as I run the php artisan migrate command, it says nothing to migrate. But I already add a Schema for adding table columns. I have read some articles and links that I should run the php artisan migrate:refresh first before the new columns to be added.The problem is, it will erase my existing data in my table. Is there any way I could perform the migration and successfully add columns in my table without deleting my data

Laravel 5.2 - pluck() method returns array

人走茶凉 提交于 2019-11-28 20:02:10
I'm trying to upgrade my project L5.1 -> L5.2. In upgrade guide there's one thing which isn't clear for me: The lists method on the Collection, query builder and Eloquent query builder objects has been renamed to pluck . The method signature remains the same. That's ok, rename refactoting from lists() to pluck() isn't a problem. But what with useful pluck() method which was in L5.0 and L5.1? From the 5.0 documentation : Retrieving A Single Column From A Row $name = DB::table('users')->where('name', 'John')->pluck('name'); What is the alternative for old pluck() method in L5.2? UPDATE: Example:

Laravel 5.2 : Web middleware is applied twice

落花浮王杯 提交于 2019-11-28 14:38:51
Here is my routes.php code Route::auth(); Route::group(['middleware' => 'web'], function () { Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth','role:Admin']], function(){ Route::get('/home', 'HomeController@index'); Route::get('user/data', ['as' => 'admin.user.data','uses'=>'UserController@userData']); Route::resource('user', 'UserController'); Route::get('merchant/data', ['as' => 'admin.merchant.data','uses'=>'MerchantController@merchantData']); Route::resource('merchant', 'MerchantController'); Route::get('bcategory/data', ['as' => 'admin.bcategory.data',

Please provide a valid cache path

落花浮王杯 提交于 2019-11-28 14:30:48
问题 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

Laravel Commands, Pthreads and Closure

折月煮酒 提交于 2019-11-28 11:05:08
问题 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

Laravel 5.2 frequently logging out

隐身守侯 提交于 2019-11-28 10:54:49
问题 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? 回答1: set your config settings of timeout from 120 to 2400. this is in minutes. in config/session.php 'lifetime' => 120 // This is in minutes 回答2: You can find session configuration in config/session.php file. Change lifetime parameter value. You may specify the number of minutes

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

帅比萌擦擦* 提交于 2019-11-28 10:52:18
问题 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()-

Which is an acceptable approach for testing commands in Laravel 5.2 with PHPUnit?

我只是一个虾纸丫 提交于 2019-11-28 09:36:11
问题 I'm trying to write test cases for Commands in PHPUnit, without much success. At this point I've tried many things, being probably this post the closest approach I found for my purpose. Still, I'm struggling a lot to get this working. Follows an example output for you: alariva@trinsic ~/timegrid.io/app $ phpunit --filter=SendBusinessReportTest PHP Warning: The use statement with non-compound name 'Artisan' has no effect in /home/alariva/timegrid.io/app/tests/unit/Console/Commands