Passed
Push — dev5 ( 2a90e7...f54fc3 )
by Ron
16:20
created

CreateFileLink::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 10
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace App\Domains\FileLinks;
4
5
use Illuminate\Support\Str;
6
use Illuminate\Support\Facades\Log;
7
use Illuminate\Support\Facades\Auth;
8
9
use App\FileLinks;
10
11
use App\Domains\FileLinks\SaveFileLinkFile;
12
use App\Http\Requests\FileLinkCreateRequest;
13
use App\Http\Requests\NewFileLinkRequest;
14
15
class CreateFileLink extends SaveFileLinkFile
16
{
17
    // //  Create a brand new file link and determine if any files should be linked to it
18
    // public function create(FileLinkCreateRequest $request)
19
    // {
20
    //     $linkID = $this->createLink($request);
21
22
    //     if($request->session()->has('newLinkFile'))
23
    //     {
24
    //         $this->relocateFiles($linkID);
25
    //     }
26
27
    //     return ['link' => $linkID, 'name' => Str::slug($request->name)];
28
    // }
29
30
    // //  Build a new link data in the database
31
    // protected function createLink($data)
32
    // {
33
    //     $link = FileLinks::create([
34
    //         'user_id'      => Auth::user()->user_id,
35
    //         'cust_id'      => $data->customerID,
36
    //         'link_hash'    => $this->generateHash(),
37
    //         'link_name'    => $data->name,
38
    //         'expire'       => $data->expire,
39
    //         'allow_upload' => isset($data->allowUp) && $data->allowUp ? true : false,
40
    //         'note'         => $data->instructions
41
    //     ]);
42
43
    //     Log::info('User '.Auth::user()->full_name.' created new file link.  Data - ', array($link));
44
    //     return $link->link_id;
45
    // }
46
47
    // //  Generate a random hash to use as the link.  Verify it is not already in use
48
    // protected function generateHash()
49
    // {
50
    //     do
51
    //     {
52
    //         $hash = strtolower(Str::random(15));
53
    //         $dup  = FileLinks::where('link_hash', $hash)->get()->count();
54
    //         Log::debug('New hash created - '.$hash.'.  Checking for duplicate.  Result - '.$dup);
55
    //     } while($dup != 0);
56
57
    //     return $hash;
58
    // }
59
}
60