public function update()
 {
     $image;
     if (Input::hasFile('image')) {
         $file = Input::file('image');
         $destinationPath = public_path() . '/mail';
         $filename = str_random(6) . '_' . $file->getClientOriginalName();
         $uploadSuccess = $file->move($destinationPath, $filename);
         //  $rate=Rate::where('id', $id)->update(array('title'   => $title,
         $image = '/mail/' . $filename;
         //                                             'content' => $content));
     }
     $id = Input::get("id");
     $title = Input::get("title");
     $content = Input::get("content");
     $mailto = Input::get("mailto");
     if (empty($image)) {
         $update_data = array('title' => $title, 'content' => $content, 'mailto' => $mailto);
     } else {
         $update_data = array('title' => $title, 'content' => $content, 'mailto' => $mailto, 'image' => $image);
     }
     $user = Mailcontent::where('id', $id)->update($update_data);
     // $user->username = $username;
     // print_r(Input::all());
     if ($user) {
         return Redirect::to('mailcontents')->withInput()->with('success', '更新成功');
     } else {
         return Redirect::to('mailcontent/' . $id)->withInput()->with('error', '更新失敗');
     }
 }
Example #2
0
Route::get('/explode.json', function () {
    $exe = DB::table("explode")->groupBy('created_at')->orderBy("created_at", "desc")->paginate(10);
    echo "<table>";
    foreach ($exe as $row) {
        $dates = DB::table("explode")->where('created_at', $row->created_at)->get();
        echo "<tr><th>" . $row->created_at . "<td>";
        echo "<th>" . count($dates) . "</th></tr>";
    }
    echo "</table>";
});
Route::post('/delImage', function () {
    DB::table("rate_pics")->where('id', Input::get("pic_id"))->delete();
});
//除刪郵件圖片
Route::post('/delMailContentImage', function () {
    $obj = Mailcontent::where('id', Input::get("id"))->first();
    echo $obj->image;
    File::delete(public_path() . $obj->image);
    $obj->image = '';
    $obj->save();
    // ->update(array('image'=>''));
});
Route::get('/downloadImage', "FrontendController@checkPas");
Route::post('/checkRatePas', "FrontendController@checkRatePas");
Route::post('/setDownloadPas', function () {
    // Rate::where('id', Input::get("rate_id"));
    $data = Input::all();
    // print_r($data);
    Rate::where('id', $data['rate_id'])->update(array('secret' => $data['val']));
});
// newsInfo