Skip to content

Commit 420f841

Browse files
committed
refact: organize
1 parent 169c94b commit 420f841

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

README.md

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ $media->data = ['additional_data' => 'new additional data']
158158
$media->save()
159159
```
160160

161-
**Note:**: Updating file name & disk will be added soon.
161+
**Note:** Updating file name & disk will be added soon.
162162

163-
**Heads Up!:** Do not update anything other than `name` & `data` using the Media instance. If you need to deal with collections, please read the docs below.
163+
**Heads Up!** Do not update anything other than `name` & `data` using the Media instance. If you need to deal with collections, please read the docs below.
164164

165165

166166

@@ -203,7 +203,7 @@ This will establish the relationship between your model and the media model.
203203

204204
Once done, you can associate media to the model as demonstrated below.
205205

206-
The first parameter of the attachMedia() method can either be a media model / id or an iterable collection of models / ids.
206+
The first parameter of the `attachMedia()` method can either be a media model / id or an iterable collection of models / ids.
207207

208208
```php
209209
$post = Post::first();
@@ -217,31 +217,6 @@ $post->attachMedia($media, 'featured-image');
217217

218218
`attachMedia()` returns number of media attached (int) on success & null on failure.
219219

220-
### Disassociate media
221-
You can use detachMedia() to disassociate media from model.
222-
223-
```php
224-
// Detach all media from all channels
225-
$post->detachMedia();
226-
227-
// Detach the specified media
228-
$post->detachMedia($media); // or 1 or [1, 2, 3] or collection of media models
229-
230-
// Detach all media of the default channel
231-
$post->clearMediaChannel();
232-
233-
// Detach all media of the specific channel
234-
$post->clearMediaChannel('channel-name');
235-
```
236-
237-
`detachMedia()` returns number of media detached (int) on success & null on failure.
238-
239-
### Synchronize association / disassociation
240-
WIP: This feature will be added soon.
241-
242-
243-
244-
245220
### Retrieve media of a model
246221
Apart from that, `HasMedia` trait enables your app models retrieving media conveniently.
247222
```php
@@ -265,6 +240,28 @@ $post->getFirstMediaUrl();
265240
$post->getFirstMediaUrl('avatar');
266241
```
267242

243+
### Disassociate media
244+
You can use `detachMedia()` to disassociate media from model.
245+
246+
```php
247+
// Detach the specified media
248+
$post->detachMedia($media); // or 1 or [1, 2, 3] or collection of media models
249+
250+
// Detach all media from all channels
251+
$post->detachMedia();
252+
253+
// Detach all media of the default channel
254+
$post->clearMediaChannel();
255+
256+
// Detach all media of the specific channel
257+
$post->clearMediaChannel('channel-name');
258+
```
259+
260+
`detachMedia()` returns number of media detached (int) on success & null on failure.
261+
262+
### Synchronize association / disassociation
263+
WIP: This feature will be added soon.
264+
268265

269266
-----
270267
## Collections

0 commit comments

Comments
 (0)