For implementing file sharing, we will need to create a new table called upload_sharing
and store all sharing-related information in that table. The following steps will explain how this is implemented in our application:
Create a new table called
upload_sharing
; this table will hold the relationship about uploads shared with users:CREATE TABLE IF NOT EXISTS uploads_sharing ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY , upload_id INT NOT NULL , user_id INT NOT NULL, UNIQUE KEY (upload_id, user_id) );
In the module definition
Module.php
, add a simpleTableGateway
object for theuploads_sharing
table:'UploadSharingTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); return new TableGateway('uploads_sharing', $dbAdapter); },
Modify the constructor of the
UploadTable
class to take in an additional parameter of the upload sharingTableGateway
object:public function __construct(TableGateway $tableGateway...