/** * Get all the tokens - not allowed without parameters, * * @return Response Collection of Resources */ public function index($input = null) { // Input is being passed as a parameter so that we can mock it easily for the tests // If it is not a test, we'll use the facade: if (!$input) { $input = Input::all(); } $data = \App\Models\SharedFileRecipient::search($input); $records = $this->getRecords($input); $data = $data->paginate($records); $collection = $this->getResourceCollectionWithPagination($data, $this->transformer); return $this->respondOK($collection); }
/** * Create a file sharing request */ public function create($input) { $user = \Auth::user(); $input['user_id'] = $user->id; $now = \Carbon\Carbon::now(); $input['expires_at'] = $now->addDays($input['expires_at'])->toDateTimeString(); $request = \App\Models\SharedFileRequest::create($input); if ($request) { foreach ($input['files'] as $file) { $fileShare = \App\Models\SharedFile::create(['request_id' => $request->id, 'file_id' => $file['id'], 'user_id' => $user->id]); $file = FSFile::find($file['id']); $file->resolvable_type = 'FileShare'; $file->resolvable_id = $fileShare->id; $file->save(); } foreach ($input['recipients'] as $recipient) { $d = \App\Models\SharedFileRecipient::create(['request_id' => $request->id, 'email' => $recipient]); } \Event::fire(new \App\Events\FileShared($request)); } return $request; }