Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Doc::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'person_id' => $this->person_id, 'type_id' => $this->type_id, 'date' => $this->date, 'date_end' => $this->date_end, 'date_renewal' => $this->date_renewal, 'duration_months' => $this->duration_months, 'duration_days' => $this->duration_days, 'address_id' => $this->address_id, 'rec_status_id' => $this->rec_status_id, 'user_id' => $this->user_id, 'dc' => $this->dc]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'series', $this->series])->andFilterWhere(['like', 'num', $this->num])->andFilterWhere(['like', 'who_give', $this->who_give])->andFilterWhere(['like', 'note', $this->note]);
     return $dataProvider;
 }
Beispiel #2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->doc) {
         $doc = Doc::find($request->doc);
     } else {
         $doc = Doc::findDocBySlug($request->slug);
     }
     $user = Auth::user();
     if (!$doc->canUserView($user)) {
         if ($request->ajax()) {
             return response('Unauthorized.', 403);
         } else {
             return redirect()->guest('auth/login');
         }
     }
     return $next($request);
 }
 public function postDate($doc)
 {
     $doc = Doc::find($doc);
     $date = Input::get('date');
     $returned = new Date();
     $returned->label = $date['label'];
     $returned->date = date("Y-m-d H:i:s", strtotime($date['date']));
     $doc->dates()->save($returned);
     return Response::json($returned);
 }
Beispiel #4
0
 public function editDocument($documentId)
 {
     if (!Auth::check()) {
         return Redirect::to('/')->with('error', 'You must be logged in');
     }
     $doc = Doc::find($documentId);
     if (is_null($doc)) {
         return Redirect::to('documents')->with('error', 'Document not found.');
     }
     if (!$doc->canUserEdit(Auth::user())) {
         return Redirect::to('documents')->with('error', 'You are not authorized to view that document.');
     }
     return View::make('documents.edit', array('page_id' => 'edit_doc', 'page_title' => "Editing {$doc->title}", 'doc' => $doc, 'contentItem' => $doc->content()->where('parent_id')->first()));
 }