laravel-5.4

Call to a member function all() on array in laravel

跟風遠走 提交于 2020-07-23 17:26:34
问题 I am getting this error: FatalErrorException in Builder.php line 485: Call to a member function all() on array my register controller namespace App\Http\Controllers\Auth; use App\User; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Validator; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Http\Request; class RegisterController extends Controller { /* |-------------------------------------------------------------------------- | Register Controller |---------

Call to a member function all() on array in laravel

你。 提交于 2020-07-23 17:20:21
问题 I am getting this error: FatalErrorException in Builder.php line 485: Call to a member function all() on array my register controller namespace App\Http\Controllers\Auth; use App\User; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Validator; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Http\Request; class RegisterController extends Controller { /* |-------------------------------------------------------------------------- | Register Controller |---------

Call to a member function all() on array in laravel

人走茶凉 提交于 2020-07-23 17:19:47
问题 I am getting this error: FatalErrorException in Builder.php line 485: Call to a member function all() on array my register controller namespace App\Http\Controllers\Auth; use App\User; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Validator; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Http\Request; class RegisterController extends Controller { /* |-------------------------------------------------------------------------- | Register Controller |---------

How to get data passed from PUT method

情到浓时终转凉″ 提交于 2020-06-26 12:11:32
问题 I am creating an API for Laravel. I use the PUT method for updating data. I send data with Postman using the PUT method. In my controller, I got an empty array. How to access the passed data? In my route, I have: Route::put('vehicletypes/{id}','API\VehicletypeController@update'); In my controller: public function update(Request $request, $id){ print_r($request->all()); exit; } How to get the data passed in PUT method? 回答1: You are getting empty response because PHP have some security

How to get data passed from PUT method

只谈情不闲聊 提交于 2020-06-26 12:10:28
问题 I am creating an API for Laravel. I use the PUT method for updating data. I send data with Postman using the PUT method. In my controller, I got an empty array. How to access the passed data? In my route, I have: Route::put('vehicletypes/{id}','API\VehicletypeController@update'); In my controller: public function update(Request $request, $id){ print_r($request->all()); exit; } How to get the data passed in PUT method? 回答1: You are getting empty response because PHP have some security

How to remove duplicates in collection?

孤街浪徒 提交于 2020-06-24 21:34:11
问题 I have collection in Laravel: Collection {#450 ▼ #items: array:2 [▼ 0 => Announcement {#533 ▶} 1 => Announcement {#553 ▶} ] } It is the same items. How ti delete one of them? Full code is: public function announcements() { $announcements = $this->categories_ann->map(function ($c) { return $c->announcements->map(function ($a) { $a->subsribed = true; return $a; }); }); $flattened = $announcements->groupBy("id")->flatten(); return $flattened; } 回答1: $unique = $collection->unique(); 回答2:

How to remove duplicates in collection?

半城伤御伤魂 提交于 2020-06-24 21:33:34
问题 I have collection in Laravel: Collection {#450 ▼ #items: array:2 [▼ 0 => Announcement {#533 ▶} 1 => Announcement {#553 ▶} ] } It is the same items. How ti delete one of them? Full code is: public function announcements() { $announcements = $this->categories_ann->map(function ($c) { return $c->announcements->map(function ($a) { $a->subsribed = true; return $a; }); }); $flattened = $announcements->groupBy("id")->flatten(); return $flattened; } 回答1: $unique = $collection->unique(); 回答2: