Commit a749365a by Aan Choesni Herlingga

bug fix categories file

parent 4102d324
......@@ -22,7 +22,7 @@ class FileRepository extends StorageRepository
return $query->with($with);
})
->when($title, function ($query) use ($title) {
return $query->where('title', 'ilike', '%' . $title . '%');
return $query->where('title', 'ilike', '%'.$title.'%');
})
->when($orderBy, function ($query) use ($orderBy) {
return $query->orderBy($orderBy[0], $orderBy[1]);
......@@ -37,28 +37,32 @@ class FileRepository extends StorageRepository
return DataTables::of($data)
->addIndexColumn()
->addColumn('action', function ($row) {
$btn = '<a href="' . url('/webprofile/file/' . $row->id . '/edit') . '" data-toggle="tooltip" data-id="' . $row->id . '" data-original-title="' . trans('label.edit') . '" class="edit btn btn-warning btn-round btn-sm edit">' . trans('label.edit') . '</a>';
$btn = '<a href="'.url('/webprofile/file/'.$row->id.'/edit').'" data-toggle="tooltip" data-id="'.$row->id.'" data-original-title="'.trans('label.edit').'" class="edit btn btn-warning btn-round btn-sm edit">'.trans('label.edit').'</a>';
$btn = $btn . ' <a href="javascript:void(0)" data-toggle="tooltip" data-id="' . $row->id . '" data-original-title="' . trans('label.delete') . '" class="btn btn-danger btn-round btn-sm delete">' . trans('label.delete') . '</a>';
$btn = $btn.' <a href="javascript:void(0)" data-toggle="tooltip" data-id="'.$row->id.'" data-original-title="'.trans('label.delete').'" class="btn btn-danger btn-round btn-sm delete">'.trans('label.delete').'</a>';
$btn = $btn . '<br>';
$btn = $btn.'<br>';
return $btn;
})
->addColumn('category', function ($row) {
if ($row->rCategoryFile) {
return ucfirst($row->rCategoryFile->name);
} else {
return '';
}
})
->addColumn('file', function ($row) use ($setting) {
if ($setting['external_storage'] == 1) {
$str = '<a href="' . $setting['url_static'] . '/' . $setting['directory'] . '/file/' . $row->file . '" style="font-size: 12pt;">'. ucfirst($row->title) .'</a>';
$str .= '<label id="furl_' . $row->id . '" hidden>' . $setting['url_static'] . '/' . $setting['directory'] . '/file/' . $row->file . '</label>';
$str = '<a href="'.$setting['url_static'].'/'.$setting['directory'].'/file/'.$row->file.'" style="font-size: 12pt;">'.ucfirst($row->title).'</a>';
$str .= '<label id="furl_'.$row->id.'" hidden>'.$setting['url_static'].'/'.$setting['directory'].'/file/'.$row->file.'</label>';
} else {
$str = '<a href="' . url('/storage/file/' . $row->file) . '" style="font-size: 12pt;">'. ucfirst($row->title) .'</a>';
$str .= '<label id="furl_' . $row->id . '" hidden>' . url('/storage/file/' . $row->file) . '</label>';
$str = '<a href="'.url('/storage/file/'.$row->file).'" style="font-size: 12pt;">'.ucfirst($row->title).'</a>';
$str .= '<label id="furl_'.$row->id.'" hidden>'.url('/storage/file/'.$row->file).'</label>';
}
$str .= '<br>';
$str .= '<button onclick="copyToClipboard(\'#furl_' . $row->id . '\')" class="btn btn-info btn-xs">Copy URL</button>';
$str .= '<button onclick="copyToClipboard(\'#furl_'.$row->id.'\')" class="btn btn-info btn-xs">Copy URL</button>';
return $str;
})
......@@ -71,6 +75,7 @@ class FileRepository extends StorageRepository
} else {
$str = '<div style="color: red;"><i class="fa fa-times"></i></div>';
}
return $str;
})
->rawColumns(['action', 'status', 'category', 'file', 'downloaded'])
......@@ -87,12 +92,14 @@ class FileRepository extends StorageRepository
]);
$headers = get_headers($url);
return stripos($headers[0], "200 OK") ? true : false;
return stripos($headers[0], '200 OK') ? true : false;
}
public function countDownload(File $file)
{
$file->downloaded = $file->downloaded + 1;
return $file->save();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment