本文整理汇总了PHP中app\File::where方法的典型用法代码示例。如果您正苦于以下问题:PHP File::where方法的具体用法?PHP File::where怎么用?PHP File::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\File
的用法示例。
在下文中一共展示了File::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendNotificationEmail
public function sendNotificationEmail(Group $group, User $user)
{
if ($user->verified == 1) {
// Establish timestamp for notifications from membership data (when was an email sent for the last time?)
$membership = \App\Membership::where('user_id', '=', $user->id)->where('group_id', "=", $group->id)->firstOrFail();
$last_notification = $membership->notified_at;
// find unread discussions since timestamp
$discussions = QueryHelper::getUnreadDiscussionsSince($user->id, $group->id, $membership->notified_at);
// find new files since timestamp
$files = \App\File::where('updated_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->get();
// find new members since timestamp
$users = QueryHelper::getNewMembersSince($user->id, $group->id, $membership->notified_at);
// find future actions until next 2 weeks, this is curently hardcoded... TODO use the mail sending interval to determine stop date
$actions = \App\Action::where('start', '>', Carbon::now())->where('stop', '<', Carbon::now()->addWeek()->addWeek())->where('group_id', "=", $group->id)->orderBy('start')->get();
// we only trigger mail sending if a new action has been **created** since last notfication email.
// BUT we will send actions for the next two weeks in all cases, IF a mail must be sent
$actions_count = \App\Action::where('created_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->count();
// in all cases update timestamp
$membership->notified_at = Carbon::now();
$membership->save();
// if we have anything, build the message and send
// removed that : or count($users) > 0
// because we don't want to be notified just because there is a new member
if (count($discussions) > 0 or count($files) > 0 or $actions_count > 0) {
Mail::send('emails.notification', ['user' => $user, 'group' => $group, 'membership' => $membership, 'discussions' => $discussions, 'files' => $files, 'users' => $users, 'actions' => $actions, 'last_notification' => $last_notification], function ($message) use($user, $group) {
$message->from(env('MAIL_NOREPLY', 'noreply@example.com'), env('APP_NAME', 'Laravel'))->to($user->email)->subject('[' . env('APP_NAME') . '] ' . trans('messages.news_from_group_email_subject') . ' "' . $group->name . '"');
});
return true;
}
return false;
}
}
示例2: displayVolunteer
/**
* Display a listing of the resource.
*
* @return Response
*/
public function displayVolunteer()
{
//Find all File
$files = File::where('type', File::VOLUNTEER)->get();
//Send the your to the index page
return view('volunteer.file.index', compact('files'));
}
示例3: handleFile
private function handleFile($root_folder, $f)
{
/*
The "black" identifier is just an abstract reference, not a real file:
we skip analysis for it
*/
if ($f == 'black') {
return true;
}
/*
This is to manage eventual files embedded multiple times: we track only
one, and eventually will substitute once all occurrences in the mlt file
when required
*/
$path = $this->guessPath($root_folder, $f);
$test_count = File::where('project_id', '=', $this->project->id)->where('original_path', '=', $path)->first();
if ($test_count != null) {
$test_count->references = $test_count->references + 1;
$test_count->save();
return true;
}
$file = new File();
$file->project_id = $this->project->id;
$file->filename = basename($f);
$file->original_path = $path;
$file->references = 1;
$ret = $file->testReach();
$file->save();
return $ret;
}
示例4: traverseInsideFolder
public function traverseInsideFolder($folderPath = 'root', $token_id)
{
// $token = User::find($this->usrId)->tokens->find($token_id);
$root = File::where('token_id', $token_id)->where('path', $folderPath)->first();
$file = $root->children()->get();
return $file;
}
示例5: IdentitasHandle
public function IdentitasHandle($req, $id)
{
// PDF tidak di update / melalui form
// Gagal mengupload file PDF
// Sukses Mengupload DOkumen
$temp_iden_pesan = ['error' => ['user' => 'Peringatan : File PDF tidak di atur dengan benar !', 'sistem' => 'Terjadi kesalahan upload File PDf '], 'succes' => ['store' => 'Sukses mengupload Dokumen PDF ', 'update' => 'Sukses mengupdate Dokumen PDF ']];
$temp_file_pesan = ['error' => '', 'succes' => ''];
// dd($req->all());
$file = $req->file('gambar');
if ($file and $file->getClientMimeType() == 'application/pdf') {
// dd($file);
$extension = $file->getClientOriginalExtension();
$FileIdentity = File::where('dokumen_id', $id);
// Update
if (count($FileIdentity->get()->toArray())) {
$this->result['identitas']['lama'] = $FileIdentity->get()->toArray();
//delete file
$data_for_update = ['mime' => $file->getClientMimeType(), 'original_filename' => $file->getClientOriginalName(), 'filename' => $file->getFilename() . '.' . $extension];
if ($FileIdentity->update($update)) {
$this->result['identitas']['baru'] = $FileIdentity->get()->toArray();
$this->{$result}['pesan'] = $temp_iden_pesan['succes']['update'];
// proses storage
if (\Storage::delete($FileIdentity->get()->toArray()[0]['filename']) && \Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) {
$this->file_pesan['succes'] = $temp_file_pesan['succes'];
return true;
} else {
$this->file_pesan['error'] = $temp_file_pesan['error'];
return false;
}
return true;
} else {
return false;
}
} else {
// echo " new file";
$new_dokument = new File();
$new_dokument->dokumen_id = $id;
$new_dokument->mime = $file->getClientMimeType();
$new_dokument->original_filename = $file->getClientOriginalName();
$new_dokument->filename = $file->getFilename() . '.' . $extension;
//new identitas
if ($new_dokument->save()) {
// new pdf
if (\Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) {
return true;
}
$this->{$result}['pesan'] = $temp_iden_pesan['succes']['store'];
return true;
} else {
$this->{$result}['pesan'] = $temp_iden_pesan['error']['sistem'];
return false;
}
}
// }
} else {
$this->{$result}['pesan'] = $temp_iden_pesan['error']['user'];
return false;
}
}
示例6: checkFilePath
public static function checkFilePath($data)
{
$var = \App\File::where('file_path', '=', $data)->first();
if ($var) {
$var = $var->file_path;
return $var;
}
}
示例7: getHistoryEvents
public function getHistoryEvents()
{
$banners = File::where('img_type', 'banner')->where("created_at", "like", $this->year . "%")->get();
if ($banners->count() == 0) {
$banners = "";
}
return view('introduction.history', compact('banners'))->with('year', $this->curYear);
}
示例8: getServer
public function getServer()
{
$server = 0;
while (File::where('server', '=', $server)->sum('size') >= 1500000000) {
$server++;
}
return $server;
}
示例9: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
$files = File::where('created_by', Auth::user()->id)->where('folder_id', $id)->get();
$folders = Folder::where('created_by', Auth::user()->id)->get();
$folder = Folder::findOrFail($id);
return view('view-folder')->with('folder', $folder)->with('folders', $folders)->with('files', $files);
}
示例10: getFileById
public function getFileById($id = 0)
{
/** @var FileModel $file */
$file = FileModel::where('id', $id)->first();
if (!$file) {
throw new NotFoundException(NotFoundException::FileNotFound);
}
return $this->buildResponse(trans('api.file.get.success'), $file);
}
示例11: getSubmissionGuidelines
public function getSubmissionGuidelines()
{
$submission = CMS::where("name", "submission")->where("type", "paper")->where("created_at", "like", $this->year . "%")->first();
$paper = File::where('img_type', "paper")->where("created_at", "like", $this->year . "%")->first();
$poster = File::where('img_type', "poster")->where("created_at", "like", $this->year . "%")->first();
$subFiles = File::where('img_type', 'submission')->where("created_at", "like", $this->year . "%")->get();
$journal = File::where('img_type', 'journal')->where("created_at", "like", $this->year . "%")->get();
return view('paper.submission', compact(['paper', 'poster', 'submission', 'subFiles', 'journal']))->with('year', $this->curYear);
}
示例12: indexPath
public function indexPath($path, Category $category, $parent = null)
{
$directory = new \DirectoryIterator($path);
$dev = stat($path)[0];
$files = [];
$directories = [];
foreach ($directory as $file) {
if ($file->isDot() || !$file->isReadable()) {
continue;
}
if ($file->isFile()) {
$node = $file->getInode();
if ($node <= 0 || $node == false) {
continue;
}
$f = File::where('dev', $dev)->where('inode', $node)->get();
if (is_null($f) || !count($f)) {
$f = new File(['dev' => $dev, 'inode' => $node]);
} else {
$f = $f->first();
}
$f->filename = $file->getFilename();
$f->size = $file->getSize();
if ($f->isDirty()) {
$f->save();
}
$files[] = $f;
} else {
if ($file->isDir()) {
$directories[] = $file->getPathname();
}
}
}
if (count($files) > 0 || count($directories) > 0) {
$pathFile = new SplFileInfo($path);
$item = Item::where('path', $pathFile->getRealPath())->get();
if (is_null($item) || !count($item)) {
$item = $category->items()->create(['title' => $pathFile->getFilename(), 'path' => $pathFile->getRealPath(), 'parent_id' => $parent]);
} else {
$item = $item->first();
}
// Files
foreach ($files as $ob) {
$ob->item()->associate($item);
$ob->save();
}
/**
* Directories
* @todo Improve recursion
*/
foreach ($directories as $dir) {
$this->indexPath($dir, $category, $item->id);
}
}
}
示例13: download
public function download($orderId, $filename)
{
$fileid = \App\File::where('filename', $filename)->first();
$orderItem = OrderItem::where('order_id', '=', $orderId)->where('file_id', $fileid->id)->first();
if (!$orderItem) {
redirect('/failed');
}
$entry = \App\File::where('filename', $filename)->first();
$file = Storage::disk('local')->get($entry->filename);
return (new Response($file, 200))->header('Content-Type', $entry->mime);
}
示例14: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$weekAgoUnix = time() - 86400 * 7;
$weekAgo = date('Y-m-d H:i:s', $weekAgoUnix);
$files = File::where('type', File::TYPE_TEMPORARY)->where('created_at', '<=', $weekAgo)->get();
foreach ($files as $file) {
$name = $file->name;
$file->delete();
unlink(storage_path('upload/' . $name));
$this->line('Deleted ' . $name);
}
}
示例15: index
public function index(Request $request)
{
if ($request->has('query')) {
$query = $request->get('query');
// build a list of public groups and groups the user has access to
$my_groups = Auth::user()->groups()->orderBy('name')->get();
$my_groups_id = [];
// using this array we can adjust the queries after to only include stuff the user has
// might be a good idea to find a clever way to build this array of groups id :
foreach ($my_groups as $the_group) {
$my_groups_id[$the_group->id] = $the_group->id;
}
$public_groups = \App\Group::where('group_type', \App\Group::OPEN)->get();
$public_groups_id = [];
// using this array we can adjust the queries after to only include stuff the user has
// might be a good idea to find a clever way to build this array of groups id :
foreach ($public_groups as $the_group) {
$public_groups_id[$the_group->id] = $the_group->id;
}
$allowed_groups = array_merge($my_groups_id, $public_groups_id);
$groups = \App\Group::where('name', 'like', '%' . $query . '%')->orWhere('body', 'like', '%' . $query . '%')->orderBy('name')->get();
$users = \App\User::where('name', 'like', '%' . $query . '%')->orWhere('body', 'like', '%' . $query . '%')->orderBy('name')->with('groups')->get();
$discussions = \App\Discussion::where('name', 'like', '%' . $query . '%')->orWhere('body', 'like', '%' . $query . '%')->whereIn('group_id', $allowed_groups)->orderBy('updated_at', 'desc')->with('group')->get();
$actions = \App\Action::where('name', 'like', '%' . $query . '%')->orWhere('body', 'like', '%' . $query . '%')->whereIn('group_id', $allowed_groups)->with('group')->orderBy('updated_at', 'desc')->get();
$files = \App\File::where('name', 'like', '%' . $query . '%')->whereIn('group_id', $allowed_groups)->with('group')->orderBy('updated_at', 'desc')->get();
$comments = \App\Comment::where('body', 'like', '%' . $query . '%')->with('discussion.group')->orderBy('updated_at', 'desc')->get();
// set in advance which tab will be active on the search results page
$groups->class = '';
$discussions->class = '';
$actions->class = '';
$users->class = '';
$comments->class = '';
$files->class = '';
// the order of those ifs should match the order of the tabs on the results view :-)
if ($groups->count() > 0) {
$groups->class = 'active';
} elseif ($discussions->count() > 0) {
$discussions->class = 'active';
} elseif ($actions->count() > 0) {
$action->class = 'active';
} elseif ($users->count() > 0) {
$users->class = 'active';
} elseif ($comments->count() > 0) {
$comments->class = 'active';
} elseif ($files->count() > 0) {
$files->class = 'active';
}
return view('search.results')->with('groups', $groups)->with('users', $users)->with('discussions', $discussions)->with('files', $files)->with('comments', $comments)->with('actions', $actions)->with('query', $query);
}
}