Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($story, CreatePart $request)
 {
     $input = $request->all();
     $story_id = $story;
     $part = new part();
     $part->story_id = $story_id;
     $part->title = $input['title'];
     $part->description = $input['description'];
     //place of part
     $position = 0;
     $current_position = Part::where('story_id', $story)->pluck('position');
     if (empty($current_positioncount)) {
         $current_position = 0;
     } else {
         $current_position;
     }
     //current_position = 1
     if ($position <= $current_position) {
         $position = $current_position + 1;
         //expect position to go to 2
     } else {
         $position = $current_position;
     }
     $part->position = $position;
     //setting position 2
     $part->save();
     //image
     $destinatonPath = '';
     $filename = '';
     $file = Input::file('image');
     $destinationPath = public_path() . '/images/parts';
     $filename = $part->id . '_' . $file->getClientOriginalName();
     $uploadSuccess = $file->move($destinationPath, $filename);
     $addimage = Part::find($part->id);
     $addimage->image = $filename;
     $addimage->save();
     return redirect('story/' . $story . '/edit');
 }
Exemplo n.º 2
0
 public function editPartDisease($pid = 0, $id = 0)
 {
     if ($pid && $id) {
         return part::getDb()->createCommand()->update('9939_part', array('part_level1' => $pid), array('id' => $id))->execute();
     }
 }
Exemplo n.º 3
0
 function getDispositionHeaderLength()
 {
     $ret = parent::getDispositionHeaderLength();
     if (!empty($this->fileName)) {
         $ret += strlen("; filename=\"");
         $ret += strlen($this->fileName);
         $ret += 1;
     }
     return $ret;
 }
Exemplo n.º 4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $editor = \Auth::user()->id;
     $author = Story::where('id', $id)->pluck('user_id');
     if ($author == $editor) {
         $state = 'on';
         $story = Story::find($id);
         $parts = part::where('story_id', $id)->get();
         $author = user::where('id', $editor)->get()->first();
         return view('story.edit', compact('story', 'state', 'parts', 'author'));
     } else {
         return redirect('story/' . $id);
     }
 }
Exemplo n.º 5
0
 /**
  * 根据条件查询部位
  * @param array $param
  * @return type
  */
 public function getSearch($param)
 {
     $array = array_intersect_key($param, $this->attributes);
     $where = '';
     $bound = [];
     foreach ($array as $k => $v) {
         if (!empty($v)) {
             $where .= ' and ' . $k . ' = :' . $k;
             $bound[':' . $k] = $v;
         }
     }
     $where = substr($where, 5);
     return part::find()->select("id,name,description,child,level")->where($where, $bound)->asArray()->all();
 }