本文整理汇总了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));
}
}
}
示例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']);
}
示例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];
}