laravel-5.3

Laravel 5.3 : Setting time zones based on users location

我只是一个虾纸丫 提交于 2019-12-12 18:47:36
问题 We have small blog application in Laravel 5.3 in which i need some suggestion about setting time stamps on the following features 1.Admin can able to send notifications to all users with current time stamp (server timezone is Asia/Calcutta) user will see all the notifications based on their time zones. 2.Users can add posts along with their current time stamps , when other users see that posts based on their time zones. So what are the changes i need to do on the timezone settings in my

ignore dev dependencies in php composer

99封情书 提交于 2019-12-12 17:01:41
问题 I have developed a composer laravel based project that I need to install on a remote production server. The problem is I have limited permission/ access so my option is to "archive" the package( using composer archive ) and unpack on the production. What folders do I need to archive and how can I ignore the dev dependencies of the package as well as vendor dev dependencies? 回答1: composer archive is likely not to help you, because this command creates an archive of a defined version of a

Laravel 5.3 migration doesn't create tables

淺唱寂寞╮ 提交于 2019-12-12 15:14:44
问题 I created some migrations using the command php artisan migrate:make and then filled it and saved it with some fields. This is a fresh installation and the first migration to run. I ran php artisan migrate and the migration completed successfully. However, while the migrations table IS created, and it has a single row with the filename and batch 1, there is no table. Here's my migration file code: use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate

Laravel 5.3 Constraining Eager Loads not working

谁说我不能喝 提交于 2019-12-12 14:00:06
问题 I have two model User and Profile in one to one relationship. I want to retrieve all user where profile.status == TRUE using following code. $users = User::with(['profile' => function ($query) { $query->where('status', TRUE); }])->get(); dd(count($users)); //50 I have 50 users and only among of them only 3 has status == TRUE . But always it display 50 . 回答1: You are getting 50 users because you are applying condition to profile . dd($user->profile) you will get only the records of the profile

Laravel at least one field is required

大城市里の小女人 提交于 2019-12-12 12:47:42
问题 I have two field billable_option and billable_option_yes . I want to validate at least one field is mandatory. I have tried: $this->validate($request,[ 'billable_option'=>'required'|'billable_option_yes'=>'required', ]); I want to check at least one field is required in Laravel-5.3 . 回答1: you can try with the required_without. $rules = array( 'billable_option' => 'required_without:billable_option_yes', 'billable_option_yes' => 'required_without:billable_option' ); 回答2: Try checking out

Laravel 5.3 Schedule Not working ( No scheduled commands are ready to run. )

血红的双手。 提交于 2019-12-12 10:51:32
问题 The below is the schedule function protected function schedule(Schedule $schedule) { $schedule->command('queue:work') ->everyMinute() ->withoutOverlapping(); } Below is the cron for laravel * * * * * /usr/local/bin/php /home/space/public_html/project/artisan schedule:run >> /home/space/public_html/project/public/op.txt 2>&1 But each time the cron outputs No scheduled commands are ready to run. queue:work is not getting executed, what am I doing wrong? 回答1: Deleting all the schedule files in

'PDOExcpetion' with message 'SQLSTATE[HY000] [2002] No route to host

安稳与你 提交于 2019-12-12 10:44:55
问题 I am facing with this problem today, while trying to connect to a remote mysql on a network. Framework used Laravel 5.3. I have configured properly the .env file with excact credentials. Yesterday was working fine. 回答1: It seems, that you have a network problem. Usually on a network ip changes from time to time. Please check the IP of the remote pc or computer on the network. If IP has changed, update again the .env file. Good luck. 来源: https://stackoverflow.com/questions/40544391

What is the difference between laravel method vs trait vs facade [closed]

霸气de小男生 提交于 2019-12-12 09:00:20
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . In a nutshell what would be the easiest way to compare the three? method vs trait vs facade Cheers! 回答1: They don't really compare because they're really different things. A method is a function that belongs to a class. class MyClass { public function this_is_a_method() { } } A

How can I use db transaction in laravel?

拥有回忆 提交于 2019-12-12 07:20:57
问题 I try this : public function destroy($id) { DB::beginTransaction(); try { $product = $this->product_repository->find($id); $result = $product->categories()->detach(); if($result) { list($status,$instance) = $this->product_repository->delete($id); } DB::commit(); return ['status'=>true,'data'=>$status]; } catch (\Exception $e) { DB::rollback(); return ['status'=>false, 'message'=>$e->getMessage()]; } } If the code executed, $this->product_repository->delete($id) not work / not success delete.

Laravel 5.3 Passport JWT Authentication

风格不统一 提交于 2019-12-12 07:08:32
问题 Earlier when I was using laravel 5.2, i used a third party package https://github.com/tymondesigns/jwt-auth/ for making JWT based authentication. Where we just had to pass the username and password to get a token. Now in laravel 5.3 with the introduction of passport I want to make a JWT based authentication but passport requires me to specify the client_id and client_secret along with the username and password. which was not there in tymondesigns/jwt-auth. If I make a request without the