Skip to content

Commit

Permalink
chore: add another example for facade
Browse files Browse the repository at this point in the history
  • Loading branch information
shukriYusof committed Oct 25, 2023
1 parent c0ba374 commit 659ac6c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ $vimeo->upload('/home/aaron/foo.mp4');

// Want to use a facade?
Vimeo::uploadImage('/videos/123/images', '/home/aaron/bar.png', true);
Vimeo::upload($video, [
'name' => NAME,
'privacy.view' => [
'anybody',
'contacts',
'disable',
'nobody',
'password',
'unlisted',
'users'
],
'folder_uri' => 'https://vimeo.com/manage/folders_name/folder_id'
]);
Vimeo::request('/videos/'. $value, ['per_page' => 2], 'GET');
```

[![Build Status](https://img.shields.io/travis/vimeo/laravel/master.svg?style=flat)](https://travis-ci.org/vimeo/laravel)
Expand Down
36 changes: 36 additions & 0 deletions src/Rules/VimeoVideoIdValidationRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace Vimeo\Laravel\Rules;

use Illuminate\Contracts\Validation\Rule;
use Vimeo\Laravel\Facades\Vimeo;

class VimeoVideoIdValidationRule implements Rule
{
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
// Make an API request to Vimeo to check if the video with the given ID exists.
// Replace 'your-api-endpoint' with the actual API endpoint you want to use.
$response = Vimeo::request('/videos/'.$value, [], 'GET');

// Check if the response status is 200, indicating a successful request.
return data_get($response, 'status') === 200;
}

/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
// Return a generic error message if the validation fails.
return __('The :attribute format is invalid.');
}
}

0 comments on commit 659ac6c

Please sign in to comment.