本文整理汇总了PHP中app\models\File::where方法的典型用法代码示例。如果您正苦于以下问题:PHP File::where方法的具体用法?PHP File::where怎么用?PHP File::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\File
的用法示例。
在下文中一共展示了File::where方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listFiles
public function listFiles($target, $target_action, $target_id)
{
$resource_type = 'App\\Models\\' . ucfirst(str_singular($target));
$uploader_id = Auth::user()->active_contact->id;
if ($target == "posts") {
if ($target_action == "create") {
$post = Post::where('author_id', $uploader_id)->where("status_id", "=", POST_DRAFT_STATUS_ID)->where("ticket_id", $target_id)->first();
} elseif ($target_action == "edit") {
$post = Post::where("id", $target_id)->first();
}
$id = isset($post->id) ? $post->id : null;
} elseif ($target == "tickets") {
if ($target_action == "create") {
$ticket = Ticket::where('status_id', TICKET_DRAFT_STATUS_ID)->where('creator_id', $uploader_id)->first();
} else {
$ticket = Ticket::where("id", $target_id)->first();
}
$id = isset($ticket->id) ? $ticket->id : null;
} elseif ($target == "people") {
$target_id = is_null($target_id) ? Auth::user()->owner->id : $target_id;
$person = Person::find($target_id);
$id = $person->id;
}
$files = is_null($id) ? [] : File::where('resource_type', $resource_type)->where("resource_id", $id)->get();
foreach ($files as $file) {
$file->size = filesize(RESOURCES . DS . $file->file_path . DS . $file->file_name);
}
return $files;
}
示例2: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$filecount = \App\Models\File::where('file_type_id', $id)->count();
if ($filecount > 0) {
return back()->withMsg('There are files in the category');
}
FileType::findOrFail($id)->delete();
return back();
}
示例3: delete
public function delete(Request $request, $banqueId, $fileId)
{
// verify request inputs
if (is_null($fileId)) {
return response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST);
} else {
$item = File::where('id_File', '=', $fileId)->delete();
return is_null($item) ? response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST) : $item;
}
}
示例4: index
public function index()
{
$fields = Field::all();
$fileTitles = File::distinct()->groupBy('parsed_title')->select('parsed_title')->get();
$fileArray = [];
foreach ($fileTitles as $title) {
$file = File::where('parsed_title', '=', $title->parsed_title)->select('parsed_date', 'full_title')->orderBy('parsed_date', 'desc');
$fileData = $file->get();
foreach ($file->get() as $multiFile) {
$fileArray[$title->parsed_title][] = $multiFile;
}
}
return view("home.index")->with('fileArray', $fileArray);
}
示例5: APIindex
/**
* API - get list of files, optionally filtered by category
*/
public function APIindex($category = null)
{
// get all files of this category
if ($category) {
if ($category == 'newest') {
// Recently added files
$files = File::orderBy('id', 'desc')->paginate(18);
} else {
$files = File::where('file_category_id', $category)->paginate(18);
}
} else {
$files = File::paginate(18);
}
return response()->json($files);
}
示例6: addComments
public function addComments(Request $request)
{
$name = $request->name;
$end = isset($request->end) ? strtotime($request->end) : time();
$start = isset($request->start) ? strtotime($request->start) : $end - 86400 * 180;
$site = isset($request->site) ? $request->site : '';
$mode = isset($request->mode) ? $request->mode : '';
$f = $s = 0;
if (empty($name) || empty($site) || empty($mode)) {
return AJAX::argumentError();
}
$file = File::where(array('name' => $name))->first();
if (empty($file) || empty($file->path)) {
return AJAX::notExist();
}
$list = $this->getFileContents($file->path);
switch ($mode) {
case 'insertComments':
$result = $this->checkCommentsFile($list, 4);
break;
case 'insertCommentsWithTid':
$result = $this->checkCommentsFile($list, 5);
break;
default:
$result['code'] = 500;
$result['data'] = 'arguments error';
break;
}
if ($result['code'] != 200) {
return AJAX::badData(array('message' => $result['message']));
}
$commentModule = new CommentModule($site);
foreach ($list as $line) {
$comment_time = $this->getCommentRandTime($start, $end);
$res = $commentModule->addCommentByLine($line, $comment_time, $mode);
if ($res['code'] != 200) {
Log::error($site . ':' . $name . $res['message']);
$f++;
continue;
}
$s++;
}
return AJAX::success(array('success' => $s, 'fail' => $f));
}
示例7: detail
public function detail($banqueId = null)
{
if (is_null($banqueId)) {
// display the hole banque
return view('banque', ['banqueItems' => Banque::all(), 'contexteItems' => Contexte::all(), 'critereItems' => Critere::all(), 'domaineItems' => Domaine::all(), 'systemeItems' => Systeme::all(), 'competenceItems' => Competence::all(), 'enseignantList' => Enseignant::all()]);
} else {
// display specific banque
$banque = $this->gestSession->getBanque($banqueId);
$items = Item::join('TitreGItem', 'TitreGItem.id_TitreGItem', '=', 'Item.id_TitreGItem')->where('Item.id_Banque', '=', $banqueId)->join('Competence', 'Item.id_Competence', '=', 'Competence.id_Competence')->get();
$auteurs = Banque_Enseignant::where('id_Banque', '=', $banqueId)->get();
$files = File::where('id_Banque', '=', $banqueId)->get();
return view("banqueDetail")->with("banque", $banque)->with("items", $items)->with("files", $files)->with("auteurs", $auteurs);
}
}
示例8: getFilesByTypeId
public function getFilesByTypeId($id)
{
$file = File::where('file_type_id', $id)->get();
return response()->json($file);
}
示例9: files
public function files($user)
{
$files = File::where("folder_id", $this->id)->where("created_by", $user->id)->orderBy("name")->get();
return $files;
}
示例10: onDelete
/**
* Function Remove
* Process Delete the Brand Data
*
* @return \Illuminate\Http\JsonResponse
*/
public function onDelete()
{
$id = Input::get('id');
$Model = \App\Models\File::select(['id', 'name'])->where('id', $id)->first();
$path = base_path() . '/public/uploads/';
if ($Model) {
File::delete($path . $Model->name);
\App\Models\File::where('id', $id)->delete();
\App\Models\FileUser::where('file_id', $id)->delete();
$param['message'] = Lang::get('message.has deleted');
$param['error'] = false;
} else {
$param['message'] = Lang::get('message.has error');
$param['error'] = true;
}
return json_encode($param);
}