laravel-5.3

usort not working for laravel multidimensional arrays

天大地大妈咪最大 提交于 2019-12-11 03:58:28
问题 I have an array Illuminate\Support\Collection Object ( [items:protected] => Array ( [0] => stdClass Object ( [id] => 79 [name] => shelin [status] => 0 ) [1] => stdClass Object ( [id] => 80 [name] => shanu [status] => 2 ) [2] => stdClass Object ( [id] => 81 [name] => linto [status] => 2 ) [3] => stdClass Object ( [id] => 82 [name] => joseph [status] => 0 ) ) ) I want to rearrange this array by status desc order I try usort($usersdetailsA, function($a, $b) { return $a->status <=> $b->status; })

Laravel multi auth - Authentication user provider [] is not defined

核能气质少年 提交于 2019-12-11 03:43:14
问题 It works when it put 'merchant' => [ 'driver' => 'session', 'provider' => 'users', ], But It shows error when I set a different table 'merchant' => [ 'driver' => 'session', 'provider' => 'merchants', ], Error: InvalidArgumentException in CreatesUserProviders.php line 40: Authentication user provider [] is not defined. What is the problem. Would you please explain me ? Thanks. 回答1: At first did you create your merchants providers? if you didnt php artisan make:provider MerchantServiceProvider

Why is Auth::attempt always returns false in Laravel 5.3?

主宰稳场 提交于 2019-12-11 03:24:58
问题 I'm new in Laravel. I try to use Multiple Auth in Laravel 5.3 and my auth.php file is: <?php return [ */ 'defaults' => [ 'guard' => 'web', 'passwords' => 'users', ], 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'token', 'provider' => 'users', ], 'courier' => [ 'driver' => 'session', 'provider' => 'couriers', ], 'client' => [ 'driver' => 'session', 'provider' => 'clients', ] ], 'providers' => [ 'couriers' => [ 'driver' => 'eloquent', 'model'

How can I add condition on mail notification laravel?

我与影子孤独终老i 提交于 2019-12-11 02:28:40
问题 I use laravel 5.3 My notication laravel like this : <?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Notifications\Messages\BroadcastMessage; class GuestRegistered extends Notification implements ShouldBroadcast, ShouldQueue { use Queueable; private $data; public function

How to create password protected archive file in PHP?

强颜欢笑 提交于 2019-12-11 01:45:00
问题 I need to be able to create an archive(zip) file with password protection using PHP. I am using Laravel 5.4 and PHP 7.1 version. I looked at this link here for ZipArchive class documentation in PHP. I also looked at here for setPassword function. But appears that creation of password protected archives is not supported. It will be a massive surprise for me if it is not possible to create password protected archive in a mature programming language such as PHP 7.1. So I guess I must be missing

How to disable csrf protection for a route with parameter?

て烟熏妆下的殇ゞ 提交于 2019-12-11 01:41:26
问题 there is a route like: Route::post('user/{id}/update','UserController@update'); I want to disable csrf protection for it, but i don't know how to add its uri into except array. 回答1: You can add the given code in VerifyCsrfToken file at App/Http/Middleware protected $except = [ 'user/*', ]; or you can disable it on route file Route::post('user/{id}/update', [ 'uses' => 'UserController@update', 'nocsrf' => true, ]); 来源: https://stackoverflow.com/questions/41757431/how-to-disable-csrf-protection

How can I use “not like” on laravel mongodb?

☆樱花仙子☆ 提交于 2019-12-11 01:37:10
问题 I see here : https://github.com/jenssegers/laravel-mongodb I try : $user = Comment::where('body', 'like', '%spam%')->get(); It works But when I try : $user = Comment::where('body', 'not like', '%spam%')->get(); It does not work Seems the library not support not like Whether there are any people who know how to circumvent this? 回答1: I believe like is converted to regex anyway, so you can do it as not regexp : $user = Comment::where('body', 'not regexp', '/spam/i'))->get(); 来源: https:/

pagination in laravel 5.3 when count of pages = 1

谁说我不能喝 提交于 2019-12-10 19:39:53
问题 I have cities table and it has 7 cities I have a view page to display these cities with 10 cities per page Controller: $cities = City::orderBy('id', 'desc')->paginate(10); return view('cities.home', compact('cities')); View: <div class="table-responsive panel panel-sky"> <table class="table table-striped table-hover"> <tr> <th>#</th> <th>Name</th> <th>Created At</th> <th>Action</th> </tr> @foreach($cities as $city) <tr id="product{{$city->id}}"> <td>{{$city->id}}</td> <td>{{$city->name}}</td>

Laravel 5.3 Passport routes is using web middleware

大城市里の小女人 提交于 2019-12-10 18:45:51
问题 Laravel 5.3 Passport component looks pretty cool, but I have some confusion on it. On documentation Passport is under API Authentication, and when set config/auth.php, it will change driver to be 'passport' of guards 'api'. Laravel 5.3 have web.php and api.php to differ routes group to use web middleware or api middleware. After installed Passport, there's a step to add Passport:routes() to AuthServiceProvider. When I run route:list it will show the new routes are all using web and auth

Laravel 5.3 Ajax Login

此生再无相见时 提交于 2019-12-10 17:33:58
问题 I'm trying to login my users with ajax with a new Laravel 5.3 project. I've generated the auth routes, which got added to my web.php: Auth::routes(); I have a html form with email, and password inputs and the csrf field. Then I also have this javascript file: $("form.login").submit(function(e) { e.preventDefault(); $.ajax({ method: "POST", dataType: "json", headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), }, data: $("form.login").serialize(), url: "/login" }) .done