PHP code example of think.studio / laravel-restricted-access

1. Go to this page and download the library: Download think.studio/laravel-restricted-access library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

think.studio / laravel-restricted-access example snippets


class File extends Model 
{
    use \LinkRestrictedAccess\Models\HasRestrictedLink;
}

/** @var RestrictedLink $shareLink */
$shareLink = $file->restrictedLinks()->make([
    'name'         => $request->input('name'),
    'pin'          => $request->input('pin'),
    'check_pin'    => $request->boolean('check_pin'),
    'check_name'   => $request->boolean('check_name'),
    'check_email'  => $request->boolean('check_email'),
]);

if ($user = $request->user()) {
    $shareLink->meta->toMorph('creator', $user);
}

$shareLink->save();

if($shareUuid = $request->string('share')) {

    $sharedLink = \LinkRestrictedAccess\RestrictedAccess::restrictedLinkModel()::query()->byKey($shareUuid)->firstOrFail();

    if ($sharedLink->needVerification() && !$sharedLink->verifiedOpenActionFromCookie($request)) {
        return // display verification view
    }

    return $sharedLink->linkable;
}
bash
php artisan vendor:publish --provider="LinkRestrictedAccess\ServiceProvider" --tag="config"
shell
php artisan migrate