function get_dl($id = null) { $digitless = ltrim($id, '0..9'); // file link can be either if ($digitless === '' or $digitless[0] === '.') { $file = File::find(strtok($id, '.')); } else { $file = File::where('name', '=', $id)->get(); } if (!$file) { return; } elseif ($this->can('file.dl.deny.' . $file->id)) { return false; } else { $path = $file->file(); $override = Event::until('file.dl.before', array(&$path, &$file, $this)); if ($override !== null) { return $override; } elseif (!$file instanceof File) { return E_SERVER; } else { // In case the model was changed during event firing. $file->save(); return Event::until('file.dl.response', array(&$path, $file, $this)); } } }
public static function factory($id = null) { $instance = new File(); if (!empty($id)) { $instance->where('id', $id)->get(); } return $instance; }
/** * Delete candidate * * @param int $id * @return Response */ public function destroy($id) { $candidate = Candidate::find($id); $files = File::where('candidate_id', '=', $candidate->id)->delete(); $candidate->delete(); return redirect()->route('candidates.index')->with('messageDelete', 'Delete candidate successfully!'); }