laravel

Laravel pass array in route

跟風遠走 提交于 2021-01-07 02:27:05
问题 Hello all I have code: {{ route('data', ['min' => 12, 'max' => 123, 'week' => 1, 'month' => 123]) }} In routes: Route::get('/data/{array?}', 'ExtController@get')->name('data'); In ExtController: class GanttController extends Controller { public function get($array = [], Request $request){ $min = $array['min']; $max= $array['max']; $week = $array['week']; $month = $array['month']; } But this is not working, I not get params in array. How I can get params in controller? I tryeid do with

Using Guzzle to perform batch request

蹲街弑〆低调 提交于 2021-01-07 01:36:03
问题 i'm working on a project where i need to perform 2000 asynchronous requests using Guzzle to an endpoint and each time i need to change the ID in the url param. the endpoint looks like this: http://example.com/api/book?id=X I tried to use a for loop to do that the only issue is that it's not asynchronous. what's the more efficient way to do such task? public function fetchBooks () { $client = new Client(); $responses = []; for ($i=1; $i < 2000; $i++) { $response = $client->post('https:/

Using Guzzle to perform batch request

为君一笑 提交于 2021-01-07 01:34:39
问题 i'm working on a project where i need to perform 2000 asynchronous requests using Guzzle to an endpoint and each time i need to change the ID in the url param. the endpoint looks like this: http://example.com/api/book?id=X I tried to use a for loop to do that the only issue is that it's not asynchronous. what's the more efficient way to do such task? public function fetchBooks () { $client = new Client(); $responses = []; for ($i=1; $i < 2000; $i++) { $response = $client->post('https:/

Using Guzzle to perform batch request

风流意气都作罢 提交于 2021-01-07 01:33:42
问题 i'm working on a project where i need to perform 2000 asynchronous requests using Guzzle to an endpoint and each time i need to change the ID in the url param. the endpoint looks like this: http://example.com/api/book?id=X I tried to use a for loop to do that the only issue is that it's not asynchronous. what's the more efficient way to do such task? public function fetchBooks () { $client = new Client(); $responses = []; for ($i=1; $i < 2000; $i++) { $response = $client->post('https:/

Full file permission is changed when uploading file to my API

让人想犯罪 __ 提交于 2021-01-07 01:30:12
问题 I am developing an application that sends images to be processed on the server. The server receives the captured image in the application and processes the image using opencv. Both the server and the application are already working and there is communication between both. The project folder, inside the server, already has all the permissions granted as shown in the image below. The problem is that when sending the application image, containing the default name 'final.png' for all images

Full file permission is changed when uploading file to my API

ぃ、小莉子 提交于 2021-01-07 01:28:31
问题 I am developing an application that sends images to be processed on the server. The server receives the captured image in the application and processes the image using opencv. Both the server and the application are already working and there is communication between both. The project folder, inside the server, already has all the permissions granted as shown in the image below. The problem is that when sending the application image, containing the default name 'final.png' for all images

how to use or import ffmpeg in a laravel controller

人走茶凉 提交于 2021-01-07 01:27:05
问题 i have already installed the laravel-ffmpeg via composer in my project composer require pbmedia/laravel-ffmpeg then i added class to config/app.php file as documentation says // config/app.php 'providers' => [ ... ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider::class, ... ]; 'aliases' => [ ... 'FFMpeg' => ProtoneMedia\LaravelFFMpeg\Support\FFMpeg::class ... ]; then publish this config file php artisan vendor:publish --provider="ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider" now my

Eloquent morphTo()->withTrashed() stopped working

坚强是说给别人听的谎言 提交于 2021-01-06 04:24:07
问题 I have a polymorphic relationship set up in an OrderItem model, where saleable can be a few different models. I've set it up like any other relationship: public function saleable() { return $this->morphTo()->withTrashed(); } This used to work fine, now all of a sudden it doesn't work and it throws the error: Call to undefined method Illuminate\Database\Query\Builder::withTrashed() I don't understand why it would have stopped working, possibly due to a composer update which may have updated

PHP Error: Call to undefined method stdClass::save() in Psy Shell code on line 1

こ雲淡風輕ζ 提交于 2021-01-05 12:56:53
问题 I'm new in Laravel, I'm using tinker to create a record: $Profile=new \App\Profile(); => App\Profile {#3038} >>> $profile->title='Premier Titre' PHP Warning: Creating default object from empty value in Psy Shell code on line 1 >>> $profile->title='Premier Titre'; => "Premier Titre" >>> $profile->description='Description'; => "Description" >>> $profile->user_id=1; => 1 >>> $profile->save() PH I have the following error:PHP Error: Call to undefined method stdClass::save() in Psy Shell code on

How can I mock external API during testing in laravel 5?

大城市里の小女人 提交于 2021-01-05 12:27:59
问题 I want to test an HTTP route in laravel. The action function of the URL calls a helper function, which calls an external API. How can I mock the external API call while testing? public function actionFunction(){ $helper = new HelperClassHelper(); return Response::json($helper->getNames()); } Here, the getNames() function makes an external API call. How do I mock it? 回答1: You can add the HelperClassHelper as a dependency in the action, and then you are able to mock it in the test: public