@@ -59,12 +59,13 @@ Each MagicLink is associated with an action, which is what will be performed
59
59
once the link is visited.
60
60
61
61
* [ Login Action] ( #login-action )
62
+ * [ Download file Action] ( #download-file-action )
63
+ * [ View Action] ( #view-action )
62
64
* [ Http Reponse Action] ( #http-response-action )
63
65
64
66
### Login Action
65
67
66
- Through the ` LoginAction ` action, you can log in to the application using the generated link
67
- by ` MagicLink ` .
68
+ Through the ` LoginAction ` action, you can log in to the application using the generated link by ` MagicLink ` .
68
69
69
70
Your constructor supports the user who will login. Optionally we can specify
70
71
the [ HTTP response] ( https://laravel.com/docs/master/responses ) using the
@@ -99,6 +100,40 @@ $urlShowView = MagicLink::create(
99
100
)->url;
100
101
```
101
102
103
+ ### Download file Action
104
+
105
+ This action, ` DownloadFileAction ` , permit create a link to download a private file.
106
+
107
+ The constructor require the file path.
108
+
109
+ Example:
110
+
111
+ ``` php
112
+ use MagicLink\Actions\DownloadFileAction;
113
+ use MagicLink\MagicLink;
114
+
115
+ // Url to download the file storage_app('private_document.pdf')
116
+ $url = MagicLink::create(new DownloadFileAction('private_document.pdf'))->url;
117
+ ```
118
+
119
+ ### View Action
120
+
121
+ With the action ` ViewAction ` , you can provide access to the view. You can use
122
+ in his constructor the same arguments than method ` view ` of Laravel.
123
+
124
+ Example:
125
+
126
+ ``` php
127
+ use MagicLink\Actions\ViewAction;
128
+ use MagicLink\MagicLink;
129
+
130
+ // Url to view a internal.blade.php
131
+ $url = MagicLink::create(new ViewAction('internal', [
132
+ 'data' => 'Your private custom content',
133
+ ]))->url;
134
+ ```
135
+
136
+
102
137
### Http Response Action
103
138
104
139
Through the ` ResponseAction ` action we can access private content without need
@@ -112,18 +147,6 @@ Examples:
112
147
use MagicLink\Actions\ResponseAction;
113
148
use MagicLink\MagicLink;
114
149
115
- $urlToViewContenct = MagicLink::create(
116
- new ResponseAction(
117
- view('promotion.code', ['code' => 'YOUR_CODE'])
118
- )
119
- )->url;
120
-
121
- $urlToDownLoadFile = MagicLink::create(
122
- new ResponseAction(function () {
123
- return Storage::download('private/docs.pdf');
124
- })
125
- )->url;
126
-
127
150
$urlToCustomFunction = MagicLink::create(
128
151
new ResponseAction(function () {
129
152
Auth::login(User::first());
0 commit comments