Skip to content

Commit 659ac6c

Browse files
committed
chore: add another example for facade
1 parent c0ba374 commit 659ac6c

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ $vimeo->upload('/home/aaron/foo.mp4');
1313

1414
// Want to use a facade?
1515
Vimeo::uploadImage('/videos/123/images', '/home/aaron/bar.png', true);
16+
Vimeo::upload($video, [
17+
'name' => NAME,
18+
'privacy.view' => [
19+
'anybody',
20+
'contacts',
21+
'disable',
22+
'nobody',
23+
'password',
24+
'unlisted',
25+
'users'
26+
],
27+
'folder_uri' => 'https://vimeo.com/manage/folders_name/folder_id'
28+
]);
29+
Vimeo::request('/videos/'. $value, ['per_page' => 2], 'GET');
1630
```
1731

1832
[![Build Status](https://img.shields.io/travis/vimeo/laravel/master.svg?style=flat)](https://travis-ci.org/vimeo/laravel)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
namespace Vimeo\Laravel\Rules;
3+
4+
use Illuminate\Contracts\Validation\Rule;
5+
use Vimeo\Laravel\Facades\Vimeo;
6+
7+
class VimeoVideoIdValidationRule implements Rule
8+
{
9+
/**
10+
* Determine if the validation rule passes.
11+
*
12+
* @param string $attribute
13+
* @param mixed $value
14+
* @return bool
15+
*/
16+
public function passes($attribute, $value)
17+
{
18+
// Make an API request to Vimeo to check if the video with the given ID exists.
19+
// Replace 'your-api-endpoint' with the actual API endpoint you want to use.
20+
$response = Vimeo::request('/videos/'.$value, [], 'GET');
21+
22+
// Check if the response status is 200, indicating a successful request.
23+
return data_get($response, 'status') === 200;
24+
}
25+
26+
/**
27+
* Get the validation error message.
28+
*
29+
* @return string
30+
*/
31+
public function message()
32+
{
33+
// Return a generic error message if the validation fails.
34+
return __('The :attribute format is invalid.');
35+
}
36+
}

0 commit comments

Comments
 (0)