function simpan($id) { if ($this->getCount($id) > 6) { echo "not"; } else { $pajak = new Pajak(); $pajak->id_pengadaan = $id; $pajak->jenis_pajak = Input::get('jenis_pajak'); $pajak->no_pajak = Input::get("no_pajak"); $pajak->tgl_pajak = date('Y-m-d', strtotime(Input::get('tanggal'))); $pajak->save(); $id_pajak = $pajak->id_pajak; if (!File::isDirectory(public_path() . '/asset/img/pajak/' . $id)) { File::makeDirectory(public_path() . '/asset/img/pajak/' . $id); } $filenpwp = Input::file('file_npwp'); $newnpwp = $id . '_' . $id_pajak . '.' . $filenpwp->guessClientExtension(); Image::make($filenpwp->getRealPath())->save(public_path('/asset/img/pajak/' . $id . '/' . $newnpwp)); $data = Pajak::find($id_pajak); $data->file_pajak = $newnpwp; if ($data->save()) { echo "ok"; } else { echo "error"; } } }