我试图寻找一个表来查看一个名为"name"的列是否存在,如果是这样返回值,如果没有创建具有空值的行,我看到firstOrCreate但我无法弄清楚如何使用它为我的生活.
这就是我现在拥有的,有人能伸出援助之手吗?
class Settings extends Eloquent
{
protected $table = 'settings';
protected $primaryKey = 'name';
public static function get($settingName)
{
return self::firstOrCreate(array('name' => $settingName));
// return self::select(array('value'))->where('name', '=', $settingName)->first()->value;
}
}
Run Code Online (Sandbox Code Playgroud) 我在做这件事时遇到了很大的问题,所以我再次寻求帮助。
我有这个庞大的文件,其中包含 Nielson 的所有 DMA,我需要用 php 以某种方式解析每个文件并从中获取数据和坐标,但它们必须以这种格式输出
{"type": "FeatureCollection", "features": [
{
"type": "Feature",
"id": "",
"properties": {
"dma": "514",
"name": "Buffalo, NY"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-79.761951, 42.269861],
[-79.14959, 42.553193],
[-79.048361, 42.691959],
[-78.853455, 42.783961],
[-78.943961, 42.978357],
[-78.881611, 43.02363],
[-78.880756, 43.02955],
[-78.890068, 43.045268],
[-78.946342, 43.072051],
[-79.06977, 43.085841],
[-79.06467, 43.262754],
[-78.520257, 43.372277],
[-77.994839, 43.36526],
[-77.997291, 43.132981],
[-77.905934, 43.133562],
[-77.951044, 43.039544],
[-77.904562, 43.023492],
[-77.95633, 42.667882],
[-78.060469, 42.532888],
[-77.722965, 42.471217],
[-77.749931, 41.998782],
[-77.609815, 41.999367],
[-77.59813, 41.478577],
[-78.050728, 41.475103],
[-78.203422, …Run Code Online (Sandbox Code Playgroud)