本文整理汇总了PHP中Illuminate\Support\Facades\Schema::getColumnListing方法的典型用法代码示例。如果您正苦于以下问题:PHP Schema::getColumnListing方法的具体用法?PHP Schema::getColumnListing怎么用?PHP Schema::getColumnListing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Schema
的用法示例。
在下文中一共展示了Schema::getColumnListing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: translate
public function translate(Request $request)
{
$data = $request->only('word', 'src_language', 'trans_language');
$validator = Validator::make($data, array('word' => 'required', 'src_language' => 'required', 'trans_language' => 'required'));
if ($validator->passes()) {
$columns = Schema::getColumnListing('translation');
// users table
if (!in_array($data['src_language'], $columns)) {
return response()->json(array('error' => 1, 'labels' => 'Source language is not available'));
} else {
if (!in_array($data['trans_language'], $columns)) {
return response()->json(array('error' => 1, 'labels' => 'Translation language is available'));
} else {
$tra = Translation::where($data['src_language'], $data['word'])->first();
if (!$tra) {
return response()->json(array('error' => 1, 'labels' => 'This word is not available in our source language'));
} else {
$data = array('word' => $data['word'], 'source' => $data['src_language'], 'target' => $data['trans_language'], 'result' => $tra->{$data}['trans_language']);
return response()->json(array('error' => 0, 'data' => $data, 'errors' => array()));
}
}
}
} else {
return response()->json(array('error' => 1, 'labels' => $validator->messages()));
}
}
示例2: search
public function search($input)
{
$query = BarcodeProcess::query();
$query->select('barcode_processes.*');
$query->leftJoin('shelves', 'barcode_processes.shelf_id', '=', 'shelves.id');
$columns = Schema::getColumnListing('barcode_processes');
$attributes = array();
foreach ($columns as $attribute) {
$attributes[$attribute] = null;
if (isset($input[$attribute]) and !empty($input[$attribute])) {
$query->where($attribute, $input[$attribute]);
$attributes[$attribute] = $input[$attribute];
}
}
/**
* Filter
*/
$this->filter($input, $query);
/**
* Get count
*/
$total = $query->count();
/**
* Pagination
*/
$this->pagination($input, $query);
/**
* Order
*/
$this->order($input, $query);
return [$query->get(), $attributes, 'total' => $total];
}
示例3: getTables
/**
* get OnData spec.
*
* @param array $data
* @return array
*/
function getTables(array $data)
{
$onData = [];
$foreignKeys = [];
$result = [];
$tmp = '';
$i = 0;
$j = 0;
foreach ($data as $key => $value) {
if ($key == 'tbl' . $i) {
$tmp = $value;
if (in_array($value, $foreignKeys)) {
throw new \Exception($value . " Relation Already selected");
}
array_push($foreignKeys, $value);
$i++;
} elseif ($key == 'on' . $j) {
if (!in_array($value, Schema::getColumnListing($tmp))) {
throw new \Exception($value . " Does not exist in " . $tmp);
}
array_push($onData, $value);
$j++;
}
}
$result[] = $onData;
$result[] = $foreignKeys;
return $result;
}
示例4: search
public function search($input)
{
$query = User::query();
$columns = Schema::getColumnListing('users');
$attributes = array();
foreach ($columns as $attribute) {
$attributes[$attribute] = null;
if (isset($input[$attribute]) and !empty($input[$attribute])) {
$query->where($attribute, $input[$attribute]);
$attributes[$attribute] = $input[$attribute];
}
}
/*
** Filter
*/
$this->filter($input, $query);
/*
** Get count
*/
$total = $query->count();
/*
** Pagination
*/
$this->pagination($input, $query);
/*
** Order
*/
$this->order($input, $query);
return [$query->get(), $attributes, 'total' => $total];
}
示例5: scopeExcludeFromFind
/**
* Exclude from find
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeExcludeFromFind(Builder $query)
{
if (isset($this->excludedFromFind) == TRUE && is_array($this->excludedFromFind) == TRUE) {
return $query->select(array_diff(Schema::getColumnListing($this->table), $this->excludedFromFind));
} else {
return $query;
}
}
示例6: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$cols = Schema::getColumnListing('comments');
unset($cols[0]);
unset($cols[2]);
unset($cols[3]);
return response()->json(array_values($cols));
}
示例7: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$cols = Schema::getColumnListing('products');
unset($cols[0]);
unset($cols[8]);
unset($cols[9]);
return response()->json(array_values($cols));
}
示例8: getColumns
public function getColumns($table = null, $class = null)
{
$class = $class ?: get_class($this);
$table = $table ?: $this->table;
if (!isset(self::$loaded_columns[$class])) {
self::$loaded_columns[$class] = Schema::getColumnListing($table);
}
return self::$loaded_columns[$class];
}
示例9: getAttributes
/**
* Get attributes from an existing table.
*
* @return array
*/
public function getAttributes()
{
//get table attributes
$this->result = Schema::getColumnListing($this->table);
//delete the first element, (ignore the id section)
unset($this->result[0]);
//get result
return $this->result;
}
示例10: search
/**
* Search the images.
*
* @param string $input
*
* @return Collection
*/
public function search($input)
{
$query = Image::orderBy('created_at', 'desc');
$query->where('id', 'LIKE', '%' . $input['term'] . '%');
$columns = Schema::getColumnListing('images');
foreach ($columns as $attribute) {
$query->orWhere($attribute, 'LIKE', '%' . $input['term'] . '%');
}
return [$query, $input['term'], $query->paginate(Config::get('quarx.pagination', 25))->render()];
}
示例11: search
public function search($term)
{
$query = $this->model->orderBy('created_at', 'desc');
$query->where('id', 'LIKE', '%' . $input['term'] . '%');
$columns = Schema::getColumnListing(str_plural($this->modelName));
foreach ($columns as $attribute) {
$query->orWhere($attribute, 'LIKE', '%' . $input['term'] . '%');
}
return ['term' => $input['term'], 'result' => $query->paginate(Config::get('quarx.pagination', 25))];
}
示例12: getAttributes
/**
* Deduce relational arttributes.
*
* @return void
*/
private function getAttributes()
{
collect($this->foreignKeys)->each(function ($key, $value) {
$Schema = collect(Schema::getColumnListing($key));
$Schema = $Schema->reject(function ($value, $key) {
return str_contains($value, 'id');
});
$this->relationAttributes[$key] = $Schema->toArray();
});
}
示例13: search
public function search($input)
{
$query = Widget::orderBy('created_at', 'desc');
$query->where('id', 'LIKE', '%' . $input['term'] . '%');
$columns = Schema::getColumnListing('widgets');
foreach ($columns as $attribute) {
$query->orWhere($attribute, 'LIKE', '%' . $input['term'] . '%');
}
return [$query, $input['term'], $query->paginate(25)->render()];
}
示例14: getClassProperties
/**
* @param string $className
*
* @return array
*/
protected static function getClassProperties($className)
{
if (\class_exists($className, true)) {
$reflection = new ReflectionClass($className);
$value = $reflection->newInstanceWithoutConstructor();
if (\is_subclass_of($value, Model::class, true)) {
$attributes = Schema::getColumnListing($value->getTable());
self::$eloquentClasses[$className] = $attributes;
}
}
return !empty(self::$eloquentClasses[$className]) ? self::$eloquentClasses[$className] : parent::getClassProperties($className);
}
示例15: getAttr
/**
* Analyse data and attributes
*
* @param Array $data
*/
private function getAttr($data)
{
foreach ($this->foreignKeys as $key => $value) {
$Schema = Schema::getColumnListing($value);
unset($Schema[0]);
foreach ($Schema as $SchemaKey => $SchemaValue) {
if (strpos($SchemaValue, '_id')) {
unset($Schema[$SchemaKey]);
}
}
$this->relationAttr[$value] = $Schema;
}
}