Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first commit #96

Open
wants to merge 1 commit into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions app/Http/Controllers/SociosController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?php

namespace App\Http\Controllers;

use App\Http\Requests\CreateSociosRequest;
use App\Http\Requests\UpdateSociosRequest;
use App\Repositories\SociosRepository;
use App\Http\Controllers\AppBaseController;
use Illuminate\Http\Request;
use Flash;
use Response;

class SociosController extends AppBaseController
{
/** @var SociosRepository $sociosRepository*/
private $sociosRepository;

public function __construct(SociosRepository $sociosRepo)
{
$this->sociosRepository = $sociosRepo;
}

/**
* Display a listing of the Socios.
*
* @param Request $request
*
* @return Response
*/
public function index(Request $request)
{
$socios = $this->sociosRepository->all();

return view('socios.index')
->with('socios', $socios);
}

/**
* Show the form for creating a new Socios.
*
* @return Response
*/
public function create()
{
return view('socios.create');
}

/**
* Store a newly created Socios in storage.
*
* @param CreateSociosRequest $request
*
* @return Response
*/
public function store(CreateSociosRequest $request)
{
$input = $request->all();

$socios = $this->sociosRepository->create($input);

Flash::success('Socios saved successfully.');

return redirect(route('socios.index'));
}

/**
* Display the specified Socios.
*
* @param int $id
*
* @return Response
*/
public function show($id)
{
$socios = $this->sociosRepository->find($id);

if (empty($socios)) {
Flash::error('Socios not found');

return redirect(route('socios.index'));
}

return view('socios.show')->with('socios', $socios);
}

/**
* Show the form for editing the specified Socios.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
{
$socios = $this->sociosRepository->find($id);

if (empty($socios)) {
Flash::error('Socios not found');

return redirect(route('socios.index'));
}

return view('socios.edit')->with('socios', $socios);
}

/**
* Update the specified Socios in storage.
*
* @param int $id
* @param UpdateSociosRequest $request
*
* @return Response
*/
public function update($id, UpdateSociosRequest $request)
{
$socios = $this->sociosRepository->find($id);

if (empty($socios)) {
Flash::error('Socios not found');

return redirect(route('socios.index'));
}

$socios = $this->sociosRepository->update($request->all(), $id);

Flash::success('Socios updated successfully.');

return redirect(route('socios.index'));
}

/**
* Remove the specified Socios from storage.
*
* @param int $id
*
* @throws \Exception
*
* @return Response
*/
public function destroy($id)
{
$socios = $this->sociosRepository->find($id);

if (empty($socios)) {
Flash::error('Socios not found');

return redirect(route('socios.index'));
}

$this->sociosRepository->delete($id);

Flash::success('Socios deleted successfully.');

return redirect(route('socios.index'));
}
}
29 changes: 29 additions & 0 deletions app/Http/Requests/CreateSociosRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use App\Models\Socios;

class CreateSociosRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return Socios::$rules;
}
}
31 changes: 31 additions & 0 deletions app/Http/Requests/UpdateSociosRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use App\Models\Socios;

class UpdateSociosRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = Socios::$rules;

return $rules;
}
}
83 changes: 83 additions & 0 deletions app/Models/Socios.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

namespace App\Models;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* Class Socios
* @package App\Models
* @version July 8, 2023, 2:50 pm UTC
*
* @property string $nombre
* @property string $telefono
* @property string $direccion
* @property string $fecha_nacimiento
* @property string $ocupacion
* @property string $correo_electronico
* @property string $tipo
*/
class Socios extends Model
{
use SoftDeletes;

use HasFactory;

public $table = 'socios';

const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';


protected $dates = ['deleted_at'];



public $fillable = [
'nombre',
'telefono',
'direccion',
'fecha_nacimiento',
'ocupacion',
'correo_electronico',
'tipo'
];

/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'id' => 'integer',
'nombre' => 'string',
'telefono' => 'string',
'direccion' => 'string',
'fecha_nacimiento' => 'string',
'ocupacion' => 'string',
'correo_electronico' => 'string',
'tipo' => 'string'
];

/**
* Validation rules
*
* @var array
*/
public static $rules = [
'nombre' => 'required|string|max:255',
'telefono' => 'required|string|max:255',
'direccion' => 'required|string|max:255',
'fecha_nacimiento' => 'required|string|max:255',
'ocupacion' => 'required|string|max:255',
'correo_electronico' => 'required|string|max:255',
'tipo' => 'required|string|max:255',
'deleted_at' => 'nullable',
'created_at' => 'nullable',
'updated_at' => 'nullable'
];


}
46 changes: 46 additions & 0 deletions app/Repositories/SociosRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace App\Repositories;

use App\Models\Socios;
use App\Repositories\BaseRepository;

/**
* Class SociosRepository
* @package App\Repositories
* @version July 8, 2023, 2:50 pm UTC
*/

class SociosRepository extends BaseRepository
{
/**
* @var array
*/
protected $fieldSearchable = [
'nombre',
'telefono',
'direccion',
'fecha_nacimiento',
'ocupacion',
'correo_electronico',
'tipo'
];

/**
* Return searchable fields
*
* @return array
*/
public function getFieldsSearchable()
{
return $this->fieldSearchable;
}

/**
* Configure the Model
**/
public function model()
{
return Socios::class;
}
}
Loading