/** * Store a newly created resource in storage. * * @param TagRequest $request * @return Response */ public function store(TagRequest $request) { if (Tag::create($request->all())) { Flash::success('添加成功!'); return Redirect::to('admin/tag'); } else { Flash::error('添加失败!'); return Redirect::back()->withInput(); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('tags')->delete(); $array = array(array("顶级标签", 0, 0, 0), array("演员", 1), array("编导", 1), array("摄影", 1), array("录音", 1), array("后期", 1), array("美术", 1), array("制片", 1), array("场务", 1), array("后勤", 1), array("活动", 1), array("男演员", 2), array("女演员", 2), array("特约演员", 2), array("群演", 2), array("主导演", 2), array("执行导演", 2), array("副导演", 2), array("编剧", 2), array("主摄影", 4), array("跟焦员", 4), array("摄影助理", 4), array("灯光", 4), array("录音师", 5), array("收音员", 5), array("录音助理", 5), array("后期导演", 6), array("剪辑", 6), array("特效", 6), array("配音", 6), array("作曲", 6), array("美术", 7), array("分镜师", 7), array("化妆师", 7), array("服装师", 7), array("制片人", 8), array("制片主任", 8), array("现场制片", 8), array("外联", 8), array("生活制片", 8), array("制作统筹", 8), array("场务", 9), array("道具师", 9), array("场记", 9), array("财务", 9), array("场地", 10), array("盒饭", 10), array("服装", 10), array("车辆", 10), array("道具", 10), array("模特", 11), array("观众", 11), array("志愿者", 11)); $count = 1; foreach ($array as $item) { Tag::create(['id' => $count, 'name' => $item[0], 'parent' => $item[1], 'editable' => count($item) > 2 ? $item[2] : 1, 'deletable' => count($item) > 3 ? $item[3] : 1]); $count += 1; } }
/** * Store a newly created resource in storage. * * @return Response */ public function store(TagsForm $result) { // try { if (Tag::create($result->all())) { Notification::success('添加成功'); return redirect()->route('backend.tags.index'); } } catch (\Exception $e) { return redirect()->back()->withErrors(array('error' => $e->getMessage()))->withInput(); } }
public function add() { $inputData = Input::get('name'); $validator = Validator::make(array('name' => $inputData), array('name' => 'required|max:255|unique:tags,name')); if ($validator->fails()) { return view('admin.error')->with(array('errors' => $validator->messages())); } try { Tag::create(array('name' => $inputData)); } catch (\Exception $e) { return view('admin.error')->with(array('errors' => "添加数据异常失败!")); } return view('admin.success')->with(array('messages' => "成功添加标签:" . $inputData)); }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('tags', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); $table->string('filename'); $table->string('name'); $table->string('slug'); $table->string('description')->default(''); }); $tags = [['name' => 'Party', 'filename' => 'noun_132751_cc'], ['name' => 'Konzert', 'filename' => 'noun_14878_cc'], ['name' => 'Vortrag', 'filename' => 'noun_57144_cc']]; collect($tags)->each(function ($tag) { Tag::create($tag); }); }
/** * Run the database seeds. * * @return void */ public function run() { $tag_array = array(); $first_add = true; $dir = "/root/blog"; $file_system = new Filesystem(); $files = $file_system->allFiles($dir); foreach ($files as $file) { $file_extension = $file_system->extension($file); if ($file_extension != 'md') { continue; } $last_dir = dirname($file); $tag_name = preg_replace('/^.+[\\\\\\/]/', '', $last_dir); $create_time_stamp = $file_system->lastModified($file); $create_time = gmdate("Y-m-d", $create_time_stamp); if ($first_add) { $tag_info = array(); $tag_info[0] = $tag_name; $tag_info[1] = $create_time; $tag_array[0] = $tag_info; $first_add = false; } $is_new = true; foreach ($tag_array as $tag) { if (strcmp($tag[0], $tag_name) == 0) { $is_new = false; } } if ($is_new) { $tag_count = count($tag_array); $tag_info = array(); $tag_info[0] = $tag_name; $tag_info[1] = $create_time; $tag_array[$tag_count] = $tag_info; } } foreach ($tag_array as $tag_io) { \App\Model\Tag::create(['name' => $tag_io[0]]); \App\Model\Category::create(['cate_name' => $tag_io[0], 'as_name' => $tag_io[0], 'parent_id' => 0, 'seo_key' => $tag_io[0], 'seo_desc' => $tag_io[0], 'created_at' => $tag_io[1], 'updated_at' => $tag_io[1]]); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $data = \Input::all(); $tag = \App\Model\Tag::create($data); return back(); }