コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $sender = Sender::findOrFail($request->sender_id);
     $beneficiary = new Beneficiary();
     foreach ($request->except('sender_id') as $key => $value) {
         $beneficiary->{$key} = $value;
     }
     //$data = $request->except('id');
     $beneficiary->save();
     $sender->sender_beneficiaries()->attach($beneficiary->id);
     return response()->success(compact('beneficiary'));
     //return response()->success(compact('data'));
 }
コード例 #2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function popup($id)
 {
     $proyecto = Project::find($id);
     $avances = Beneficiary::avances($proyecto->id);
     if (count($avances) > 0) {
         $fecha_visita = $avances->last()->created_at;
     } else {
         $fecha_visita = null;
     }
     $actividades = Beneficiary::actividades($proyecto->id);
     $beneficiarios = Beneficiary::beneficiarios($proyecto->id);
     return view('admin.informes.pupup', compact('proyecto', 'fecha_visita', 'actividades', 'beneficiarios'));
 }
コード例 #3
0
ファイル: routes.php プロジェクト: JohanArmando/ProyectoGrado
/*Routes Residente*/
Route::group(['namespace' => 'Resident', 'prefix' => 'resident', 'middleware' => ['auth']], function () {
    Route::get('home', ['as' => 'home', 'uses' => 'HomeController@getHome']);
    Route::post('proyecto/avance', ['as' => 'residente.proyecto.avance', 'uses' => 'AvanceController@avanceProyecto']);
    Route::post('proyecto/avance/add', ['as' => 'residente.avance.add', 'uses' => 'AvanceController@addAvance']);
    Route::get('last/advanced', ['as' => 'residente.avance.last', 'uses' => 'AvanceController@last']);
    Route::get('users', ['as' => 'residente.users', 'uses' => 'AvanceController@users']);
    Route::get('all', ['as' => 'residente.all', 'uses' => 'AvanceController@all']);
    Route::resource('advanced', 'AvanceController');
});
/*Routes admin*/
Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth', 'admin']], function () {
    Route::get('home', function () {
        $residents = \App\Resident::where('type', '<>', 'admin')->count();
        $projects = \App\Project::count();
        $beneficiaries = \App\Beneficiary::count();
        $disenos = \App\Desing::count();
        return view('admin.home', compact('projects', 'residents', 'beneficiaries', 'disenos'));
    });
    Route::post('delete/stage/project', ['as' => 'detele.staage.project', 'uses' => 'ProjectController@deleteStageProject']);
    Route::get('opciones/proyecto', ['as' => 'option.project', 'uses' => 'ProjectController@opciones']);
    Route::post('etapas/proyecto', ['as' => 'admin.project.stage', 'uses' => 'ProjectController@stageProject']);
    Route::post('all/stage', ['uses' => 'ProjectController@allStage']);
    Route::post('nothing/stage', ['uses' => 'ProjectController@nothingStage']);
    Route::post('etapas/proyecto/dos', ['as' => 'admin.add.stage.project', 'uses' => 'ProjectController@stageProjectAdd']);
    Route::resource('proyectos', 'ProjectController');
    Route::post('benficiarios/cambiar/proyecto/', ['as' => 'admin.beneficiarios.change-project', 'uses' => 'BeneficiarioController@changeProject']);
    Route::get('beneficiario/project/{id}', ['as' => 'admin.project.beneficiario', 'uses' => 'BeneficiarioController@directBen']);
    Route::post('residente/change/project/', ['as' => 'admin.residentes.change-project', 'uses' => 'ResidenteController@changeProject']);
    Route::get('residente/project/{id}', ['as' => 'admin.project.residente', 'uses' => 'ResidenteController@directRe']);
    Route::resource('beneficiarios', 'BeneficiarioController');
コード例 #4
0
 public static function beneficiarios($id)
 {
     return Beneficiary::join('projects', 'projects.id', '=', 'beneficiaries.project_id')->leftJoin('advanceds', 'advanceds.beneficiary_id', '=', 'beneficiaries.id')->where('projects.id', '=', $id)->orderBy('beneficiaries.id', 'ASC')->groupBy('beneficiaries.id')->get(['beneficiaries.*', DB::raw("GROUP_CONCAT(advanceds.state SEPARATOR ',') AS state")]);
 }
コード例 #5
0
 public function users()
 {
     $users = Beneficiary::where('residents.id', '=', Auth::user()->id)->leftJoin('projects', 'projects.id', '=', 'beneficiaries.project_id')->leftJoin('project_resident', 'project_resident.project_id', '=', 'projects.id')->leftJoin('residents', 'residents.id', '=', 'project_resident.resident_id')->orderBy('beneficiaries.name', 'DESC')->select(['beneficiaries.*', 'projects.name as name_p'])->paginate(5);
     return view('residente.user', compact('users'));
 }
コード例 #6
0
 public function directBen($id)
 {
     $proyecto = Project::find($id);
     $homes = Beneficiary::where('project_id', '=', $proyecto->id)->get();
     $boolean = false;
     if (count($homes) >= $proyecto->quantity) {
         Session::flash('message', 'Este proyecto tiene el maximo numero de beneficiarios');
         return redirect()->to('admin/proyectos');
     } else {
         return view('admin.beneficiario.create', compact('proyecto', 'boolean'));
     }
 }