Beispiel #1
0
 public function testCheckIfFilePutWorks()
 {
     $path = __DIR__ . '/dummy/foo';
     File::put($path, 'bar');
     $this->assertTrue(File::exists($path), "Couldn't write files");
 }
 /**
  * Set the attachement.
  *
  * @param string $path
  */
 public function attach($file)
 {
     if (File::exists($file)) {
         $filename = explode('/', $file)[count(explode('/', $file)) - 1];
         $mime = mime_content_type($file);
         $attachment = new \Sendgrid\Attachment();
         $attachment->setContent(File::get($file));
         $attachment->setType($mime);
         $attachment->setFilename($filename);
         $attachment->setDisposition('attachment');
         $attachment->setContentId($filename);
         $this->mail->addAttachment($attachment);
     }
     return $this;
 }
Beispiel #3
0
 /**
  * creates folder recursively if there's none
  * must have a prefix, by default /public.
  *
  * @param  string $path Path to be created
  */
 public function directorize($path)
 {
     $folders = explode('/', $path);
     $pathbuild = $this->prefix;
     foreach ($folders as $folder) {
         $pathbuild .= "{$folder}/";
         $cond = File::exists($pathbuild) && File::isDirectory($pathbuild);
         if (!$cond) {
             File::makeDirectory($pathbuild);
             File::put("{$pathbuild}.gitkeep", 'Generated by `anekdotes/manager`');
         }
     }
 }