當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Attachment::where方法代碼示例

本文整理匯總了PHP中Attachment::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Attachment::where方法的具體用法?PHP Attachment::where怎麽用?PHP Attachment::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Attachment的用法示例。


在下文中一共展示了Attachment::where方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getAttachment

 /**
  * 
  * @param string $action view|download|base64
  * <p><b>view: </b>presenta el archivo en el navegador</p>
  * <p><b>download: </b>descarga el archivo</p>
  * <p><b>base64: </b>envia el archivo en base64</p>
  * @param int $id
  * @param string $key MD5($id . MD5('lorapp')). Evita que al cambiar $id se muestre otro archivo
  * @return file
  */
 public static function getAttachment($action, $id, $key = null)
 {
     $data = '';
     if ($key == MD5($id . MD5('lorapp'))) {
         $file = Attachment::find($id);
         $name = $file->name;
         $mime = $file->mime;
         $size = $file->size;
         $encode = $file->encode;
         $data = $file->file;
         if ($encode == 'base64') {
             $data = base64_decode($file->file);
         }
         $upload_path = $file->upload_path;
         if ($upload_path) {
             $upload_path = $file_path = public_path() . DIRECTORY_SEPARATOR . $file->upload_path . DIRECTORY_SEPARATOR . $file->name;
             $data = file_get_contents($upload_path);
         }
         if ($action == 'view') {
             return Response::make($data, 200, array('Content-type' => $mime, 'Content-length' => $size));
         } else {
             if ($action == 'download') {
                 return Response::make($data, 200, array('Content-type' => $mime, 'Content-length' => $size, 'Content-Disposition' => 'attachment; filename=' . $name));
             } else {
                 if ($action == 'base64') {
                     return 'data:' . $file->mime . ';base64,' . $data;
                 }
             }
         }
     } else {
         if ($action == 'name') {
             $file = Attachment::where('name', '=', $id)->first();
             $name = $file->name;
             $mime = $file->mime;
             $size = $file->size;
             $encode = $file->encode;
             $data = $file->file;
             if ($encode == 'base64') {
                 $data = base64_decode($file->file);
             }
             $data = $file->file;
             return Response::make($data, 200, array('Content-type' => $mime, 'Content-length' => $size));
         } else {
             return Response::make($data, 200, array('Content-type' => '', 'Content-length' => 0));
         }
     }
 }
開發者ID:alexlondon07,項目名稱:accounting,代碼行數:57,代碼來源:AttachmentController.php

示例2: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($user_id)
 {
     $entry = User::findOrFail($user_id);
     $user = $entry['username'];
     $entry->delete();
     $count = Logbook::where('user_id', '=', $user_id)->count();
     $logbooks = Logbook::where('user_id', '=', $user_id)->update(array('user_id' => 0));
     $tasks = Task::where('user_id', '=', $user_id)->update(array('user_id' => 0));
     $attachments = Attachment::where('user_id', '=', $user_id)->update(array('user_id' => 0));
     if ($count == 1) {
         return Redirect::to(route('settings.index'))->with('message', ['content' => 'Gebruiker met succes verwijderd! Let op, ' . $count . ' logboek van gebruiker ' . $user . ' is veranderd naar eigenaar Systeem!', 'class' => 'warning']);
     } else {
         if ($count > 1) {
             return Redirect::to(route('settings.index'))->with('message', ['content' => 'Gebruiker met succes verwijderd! Let op, ' . $count . ' logboeken van gebruiker ' . $user . ' zijn veranderd naar eigenaar Systeem!', 'class' => 'warning']);
         }
     }
     return Redirect::to(route('settings.index'))->with('message', ['content' => 'Gebruiker met succes verwijderd!', 'class' => 'success']);
 }
開發者ID:l0ngestever,項目名稱:logboek,代碼行數:24,代碼來源:UsersController.php

示例3: files

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function files($contract_guid)
 {
     $attachments = Attachment::where('mailbox_id', $contract_guid)->get();
     $apiEntries = [];
     foreach ($attachments->toArray() as $attachment) {
         if (strrpos(basename($attachment['original_path']), '.')) {
             $extension = substr(basename($attachment['original_path']), strrpos(basename($attachment['original_path']), '.'));
         } else {
             $extension = ".extensionless";
         }
         $local_url = 'https://' . Config::get('app.content_host') . '/dropbox/' . $attachment['file_sha'] . $extension;
         $remote_url = 'https://' . Config::get('app.dropbox_host') . '/context.io/download/' . $attachment['id'];
         $created_at = Carbon::createFromFormat('Y-m-d H:i:s', $attachment['created_at'])->toRFC2822String();
         $updated_at = Carbon::createFromFormat('Y-m-d H:i:s', $attachment['updated_at'])->toRFC2822String();
         $apiEntry = ['local_url' => $local_url, 'remote_url' => $remote_url, 'original_path' => $attachment['original_path'], 'mime_type' => $attachment['mime_type'], 'bytes' => $attachment['bytes'], 'service_created_at' => $attachment['service_created_at'], 'service_updated_at' => $attachment['service_updated_at'], 'client_created_at' => $attachment['client_created_at'], 'client_updated_at' => $attachment['client_updated_at'], 'created_at' => $created_at, 'updated_at' => $updated_at, 'file_sha' => $attachment['file_sha'], 'etag' => $attachment['etag']];
         $apiEntries[] = $apiEntry;
     }
     return [$apiEntries];
 }
開發者ID:andrewpurkett,項目名稱:demo-dropbox-rest-service,代碼行數:25,代碼來源:ContextIOCrawlerController.php


注:本文中的Attachment::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。