robbiepaul / cloudconvert-laravel

A Laravel wrapper for the CloudConvert API
177 stars 34 forks source link

How can i get the Process ID directly #31

Closed AmirAmin closed 8 years ago

AmirAmin commented 8 years ago

Hello,

Right now i would like to run a conversion command and return the process id to store it in the database, to compare it in the callback to get the download url for the process in case i am running more than one conversion.

Regards,

AmirAmin commented 8 years ago

For ex. how can i get the process id of the following conversion command :

CloudConvert::file('xyz.mp3') ->callback('http://myserver.com/save_file.php') ->convert('wav');

josiasmontag commented 8 years ago

Hello, please have a look at #26.

AmirAmin commented 8 years ago

Worked Perfect,

I played around it by getting the list of the processes, Convert it into Collective, and select last element which is the recent converted as per the following:

$processes = collect(CloudConvert::processes()); $processId = $processes[count($processes) - 1]->id;

Thanks a lot bro.

robbiepaul commented 8 years ago

Thanks @josiasmontag

@AmirAmin Good stuff. CloudConvert::processes() already returns as Illuminate\Support\Collection. So you could simplify your code to:

$processes = CloudConvert::processes(); 
$processId = $processes->last()->id;

See the Laravel docs: https://laravel.com/docs/master/collections#method-last