laravel-5.2

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

删除回忆录丶 提交于 2019-11-29 15:32:37
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/SendBusinessReportTest.php on line 4 PHP Stack trace: PHP 1. {main}() /usr/bin/phpunit:0 PHP 2. PHPUnit_TextUI

Fetch Api:Can not get data from localhost

孤街浪徒 提交于 2019-11-29 15:25:51
I have been trying to create an android app using nativescript.I am using fetch module to get response from my server.When I am trying to get response from httpbin.org/get ,it is OK.But when I am trying to get response from my local server,I am getting Network Request Failed. error. Sending to httpbin.org/get- return fetchModule.fetch("https://httpbin.org/get").then(response => { return response.text(); }).then(function (r) { console.log(r); }, function (e) { console.log(e); }); Sending to localhost:8000/api- return fetchModule.fetch("http://localhost:8000/api").then(response => { return

Laravel 5.2 - How to logout a user from all of his devices

a 夏天 提交于 2019-11-29 14:19:36
问题 When a user logged out from a perticular device I want to logout from all the device he has logged in till now . How I do it in Laravel. I have used Redis for keeping the userId in Session by installing "predis/predis": "~1.0" And Here is my controller for SignIn and Logout: public function postSignIn(Request $request) { if (Auth::attempt(['email' => $request['email'], 'password' =>$request['password'] ]) ) { $redis = \Redis::connection(); $userId=Session::getId(); $redis->sadd('users

Fatal error: Call to undefined method GuzzleHttp\\Client::request() with Guzzle 6

邮差的信 提交于 2019-11-29 13:40:55
I'm using Guzzle 6 with Laravel 5.2. I'm trying to access a simple internal API: use GuzzleHttp\Client; $client = new Client(['base_uri' => getenv('URL_BASE').'api/v1/']); $response = $client->request('GET', 'tournaments'); And I get this message: Fatal error: Call to undefined method GuzzleHttp\Client::request() When I see the docs , it says: $client = new GuzzleHttp\Client(['base_uri' => 'https://foo.com/api/']); But PHPStorm cannot resolve GuzzleHttp What should I do to make it work??? I am also using guzzle, and its working for me, Try like this use GuzzleHttp; use GuzzleHttp\Subscriber

How to make SQLite work in Laravel

馋奶兔 提交于 2019-11-29 11:31:11
问题 Whenever I run php artisan migrate , the following error is shown in the console: [PDOException] SQLSTATE[HY000] [14] unable to open database file The database.sqlite file is located at database/ . I'm running Windows 10 , Laravel 5.2 . Here is .env file config: .env: DB_CONNECTION=sqlite DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=database DB_USERNAME=homestead DB_PASSWORD=secret I have looked everywhere, but could not find what causes this error and how to resolve it. Update I managed to

Laravel SwiftMailer : Expected response code 250 but got code “530”, with message \"530-5.5.1 Authentication Required

别等时光非礼了梦想. 提交于 2019-11-29 11:04:25
I am using laravel 5.2, And the using Swift Mailer for password resetting. I have 2-step verification on my gmail. . As the google help says : If you've turned on 2-Step Verification for your account, you might need to enter an App password instead of your regular password. I have the following settings on mail.php : return [ 'driver' => env('MAIL_DRIVER', 'smtp'), 'host' => env('MAIL_HOST', 'smtp.gmail.com'), 'port' => env('MAIL_PORT', 465), 'from' => ['address' => 'meaprogrammer@gmail.com', 'name' => 'Shafee'], 'encryption' => env('MAIL_ENCRYPTION', 'ssl'), 'username' => env('meaprogrammer

Laravel 5.2: Unable to locate factory with name [default]

℡╲_俬逩灬. 提交于 2019-11-29 10:43:25
问题 I want to seed database when I use this public function run() { $users = factory(app\User::class, 3)->create(); } Add three user in database but when I use this public function run() { $Comment= factory(app\Comment::class, 3)->create(); } Show me error [InvalidArgumentException] Unable to locate factory with name [default] [app\Comment]. 回答1: By default the laravel installation comes with this code in the database/factories/ModelFactory.php File. $factory->define(App\User::class, function

How to use 'OR' middleware for route laravel 5

北城余情 提交于 2019-11-29 09:38:52
I've two types for user and I've created multiple middlewares. Some routes need to allow for both type of user. I've trying following code: Route::group(['namespace' => 'Common', 'middleware' => ['Auth1', 'Auth2']], function() { Route::get('viewdetail', array('as' => 'viewdetail', 'uses' => 'DashboardController@viewdetail')); }); But its not working :( Middleware is supposed to either return a response or pass the request down the pipeline. Middlewares are independent of each other and shouldn't be aware of other middlewares run. You'll need to implement a separate middleware that allows 2

Multiple Laravel 5 projects on the same domain

喜你入骨 提交于 2019-11-29 08:46:20
I got several Laravel 5 projects running on subfolders, on the same domain. Each Laravel application is generating it's own session cookie, and sometimes it generates so much that we get http 400 errors on the entire domain. Should I share the storage folder between all those projects, or there's any settings to prevent that to happen? Each Laravel installation should be located in its own directory. Then an alias needs to be defined which points the domain sub-folder to the "child" Laravel folder. Example in Apache http.conf : <VirtualHost some.domain:80> ServerName some.domain ## Path to

Laravel 5.2: Integrate entrust package, create role and permissions and access it

风格不统一 提交于 2019-11-29 08:28:06
I am totally new in laravel. I install laravel 5.2 . I have done with CRUD in laravel. Now i want to integrate laravel authentication package. so i choose zizaco\entrust. I follow each steps from doc link . but i don't understand what is wrong. In doc there is not mentioned that in which file i have to add following code. $owner = new Role(); $owner->name = 'owner'; $owner->display_name = 'Project Owner'; // optional $owner->description = 'User is the owner of a given project'; // optional $owner->save(); $admin = new Role(); $admin->name = 'admin'; $admin->display_name = 'User Administrator';