laravel-5.3

NOAUTH Authentication required. Laravel + Redis

孤街醉人 提交于 2019-12-06 03:49:41
问题 I am getting error NOAUTH Authentication required . My laravel version is 5.3 and I am using predis 1.1.1 to connect redis. in etc/redis/redis.conf I have: bind 127.0.0.1 requirepass somepassword in .env file I have REDIS_HOST=127.0.0.1 REDIS_PASSWORD=somepassword REDIS_PORT=6379 in config/database.php I have: 'redis' => [ 'cluster' => false, 'default' => [ 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => 0,

Laravel - Remove elements having NULL value from multidimentional array

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 03:38:35
问题 I am using Laravel 5.3 . I have a multidimensional array like: Array ( [id] => 37141 [last_done_on] => [] [children] => Array ( [0] => NULL /* This must be removed */ [1] => Array ( [id] => 37142 [last_done_on] => Array() [children] => Array() ) [2] => Array ( [id] => 37143 [last_done_on] => Array() [children] => Array ( [0] => Array ( [id] => 37144 [last_done_on] => Array() [children] => Array() ) [1] => Array ( [id] => 37145 [last_done_on] => Array() [children] => Array() ) ) ) [3] => Array

Checking if User is activated before sending Password Reset email using Forgot Password

China☆狼群 提交于 2019-12-05 18:04:42
I'm creating a small app using Laravel 5.3 . I've applied user activation (via email confirmation) on Laravel's default Auth . But i couldn't find a way to stop sending password reset link if account/user not activated by verifying email address. Currently if a user creates an account and doesn't verify the email address he/she can login using Password Reset link. this what i've in user table public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name')->nullable();; $table->string('username')->unique(); $table->string('email')-

Identifying and persisting guest users in Laravel

China☆狼群 提交于 2019-12-05 17:53:10
I am building an online store website as a side project with Laravel 5.3. My goal is to implement anonymous and authenticated shopping. Here are the Customer , Cart , and CartItem tables so far: // (1) customers table... table->increments('id'); $table->integer('user_id')->unsigned(); // -> User hasOne('App\Customer') rel. $table->string('first_name'); // last_name, dob, phone, etc. + timestamps // (2) carts table... $table->increments('id'); // -> Customer identification (and not user_id, because admins don't have carts!): $table->integer('customer_id')->unsigned()->nullable(); // -> Guest

Laravel Carbon localization not working (get localized name of month from number)

血红的双手。 提交于 2019-12-05 15:50:56
Using Laravel 5.3, In my method I use setlocale(LC_TIME, 'hr-HR'); dd(Carbon::now()->formatLocalized('%A')); but I get Sunday instead of CroatianWordForSunday . I tried using Carbon::setLocale('hr') instead setlocale() but I still get Sunday . In my config/app.php file I have set 'locale' => 'hr' . Thing to note is that Carbon's diffForHumans() method is successfully translated if I use Carbon::setLocale('hr') . In the end all I'm trying to do is convert number 8 to August but in Croatian. I could always just manually change January to Siječanj and so on but it would be nice if it could be

Multiple auth for laravel

对着背影说爱祢 提交于 2019-12-05 12:54:09
I want to split middleware auth to two role one is for admin and second for user but some route is use for all user and admin and few route is for admin only how can i split with route? Auth::routes(); Route::group(['middleware' => 'auth'], function () { //Some route here }); Route::group(['middleware' => ['guest']], function () { //some route here }); Here is my implementation for access control for admin and users(agents in my case) I have a boolean field in my user table ( is_admin ) which is 0 for normal users and 1 for admins. In your User model add this: protected $casts = [ 'is_admin' =

Validate an array of integers

馋奶兔 提交于 2019-12-05 11:29:37
Given an array of integers: [1, 2, 3, 4, ...] How can I use the validator to check if each of these exists in a table? Possible without a foreach loop? $validator = Validator::make($request->all(), [ 'array' => 'required|exists:users,id' ]); Your validation as written should work. If the exists validation is used with an array, it will automatically use where in for the exists query. So, given your validation as you have written, the validation will get the count of the users records where the id field is in the list of ids provided by your array input. Therefore, if your array is [1, 2, 3, 4]

Laravel 5.3 How to show Username in Notifications Email

北慕城南 提交于 2019-12-05 10:44:22
I am trying to add the user's first name in the notification emails. At the moment, Laravel notification emails starts like: Hello, And I want to change it to: Hello Donald, Right now, I have a set-up like this. This example is for a Password Reset Notification email: User Model: public function sendPasswordResetNotification($token) { $this->notify(new PasswordReset($token)); } App\Notifications\PasswordReset: class PasswordReset extends Notification { use Queueable; /** * Create a new notification instance. * * @return void */ public function __construct() { // } /** * Get the notification's

query that worked in Laravel 5.2 give me error in Laravel 5.3

只谈情不闲聊 提交于 2019-12-05 06:16:32
This query works in 5.2: $galleries = Gallery::with(array( 'images' => function ($query) { $query->orderBy('order', 'asc'); } )) ->with('votes') ->leftJoin('votes', 'votes.votable_id', '=', 'gallery.id') ->selectRaw( 'gallery.*, count(case votes.status when "upvote" then 1 else null end) - count(case votes.status when "downvote" then 1 else null end) as points' ) ->where('votes.votable_type','App\Gallery') ->groupBy('gallery.id') ->orderBy('points', 'desc') ->published()->orderBy('gallery.created_at', 'desc')->paginate(30); I am trying to select all galleries that have votes, when I run this

Laravel Passport Password Grant Tokens: own mobile app

依然范特西╮ 提交于 2019-12-05 02:52:55
问题 so my mobile app would be the client, i generated a client_id and a client_secret for it. users who uses the mobile app have to login using their username/password. Where should i store the client_id and client_secret? is it ok to expose them and simply place them hardcoded in the app? 回答1: It is definitely not the secure way of hardcoding them and just placing them in an app. Actually its not that straight forward. I assume you created the client from artisan or from the pre-built Vue