sergionc

sergionc

Member Since 1 Year Ago

Experience Points
1,370
Total
Experience

3,630 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
1,370 XP
May
01
3 months ago
Activity icon

Started a new Conversation Invalid Argument Supplied For Foreach With Livewire

Greetings friends, I have a problem and I cannot understand. I am using livewire, I have a button that when I click it brings me to all the users

class AsignarNota extends Component { public $usuarios;

public function render()
{
	$cursos = Curso::all();
	return view('livewire.asignar-nota',compact('cursos'));
}

public function usuarios()
{
	$this->usuarios = User::all();
}

}

		<tbody>
			<tr>
				@foreach ($usuarios as $usuario)
				<th scope="row">{{ $usuario->id }}</th>
				@endforeach
			</tr>
		</tbody>

Invalid argument supplied for foreach().

Apr
28
3 months ago
Apr
27
3 months ago
Activity icon

Replied to Search Data In Related Model

Trying to get property 'name_course' of non-object

Activity icon

Started a new Conversation Search Data In Related Model

Hello, I have 2 related.

Model course: id, name_course

Model materiales: id, tag, url_material, course_id

I can do the search by: tag, if I wanted to do the search by course name?

public function render()
{
    $materiales = Material::with('course')
    ->where('tag', 'like', '%' . trim($this->searchInput) . '%')
    ->orderBy('id', 'DESC')
    ->paginate($this->pagination);
    return view('livewire.live-material', compact('materiales'));
}

if i add this: ->where('name_course', 'like', '%' . trim($this->searchInput) . '%')

shows error, because it is not in the collection

relationship model:

public function course()
{
	return $this->belongsTo(Course::class);
}
Apr
24
3 months ago
Activity icon

Started a new Conversation Count Records In Related Table

I have this function that teachers count, of course this is from a related table. (Everything works well) My query: is there another way to summarize this function?

public function index()
{
    $docentes = User::whereHas(
        'roles',
        function ($q) {
            $q->where('nombre_rol', 'docente');
        }
    )->get();
    $nro_docentes = $docentes->count();
  	return view('escritorio.index',compact('nro_docentes'));
}
Apr
06
4 months ago
Activity icon

Replied to Delete Record With Fetch Api

It works fine, I usually delete a record like this:

              <form action="{{route('persona.destroy', $persona->id)}}"
                            class="d-inline" method="post">
                            @csrf
                            @method('delete')
                            <button class="btn btn-danger btn-sm btnhola" type="submit">
                                <i class="fas fa-times">
                                </i>
                            </button>
                        </form>

Now I want to do it through fetch api js vanilla.

Activity icon

Started a new Conversation Delete Record With Fetch Api

I am trying to delete a record using fetch api but I get the following error: The GET method is not supported for this route. Supported methods: DELETE.

button:

                        <button class="btn btn-danger btn-sm"
                            onclick="deletePersona({{$persona->id}})">
                            <i class="fas fa-times">
                            </i>
                        </button>

Code js:

function deletePersona(id) { fetch("/persona_eliminar/" + id, { method: "DELETE", }) .then((res) => res.json()) .then((response) => { console.log(response); }); }

Apr
02
4 months ago
Activity icon

Replied to Select Dynamic With Livewire

@Snapey I have followed the example to the letter, but it throws the same error: Unresolvable dependency resolving [Parameter #0 [ $country ]] in class App\Http\Livewire\SelectCiudad...

Activity icon

Started a new Conversation Select Dynamic With Livewire

Hello friends, I am trying to do dynamic select using livewire, any help?

Component:

public $ciudades=[];

public function render()
{
    $regiones = Region::all();
    return view('livewire.select-ciudad',compact('regiones'));
}

public function showciudades($id)
{
    $this->ciudades = Ciudad::where('region_id', '=',$id)->get();
}

View, select father :

    <select class="form-control" style="width: 100%">
        @foreach ($regiones as $region)
            <option value="{{ $region->id }}" wire:click="showciudades({{$region->id}})">
                {{ $region->nombre_region }}
            </option>
        @endforeach
    </select>

Select son:

    <select name="ciudad_id" class="form-control" style="width: 100%">
        @foreach($ciudades as $ciudad)
        <option value="{{$ciudad->id}}">{{$ciudad->nombre_ciudad}}</option>
        @endforeach
    </select>
Mar
12
5 months ago
Activity icon

Replied to Optimize Query Line

excellent, thanks for the clarification.

Activity icon

Replied to Optimize Query Line

@jlrdw I would like to use something like this: Alumno::create();

Activity icon

Started a new Conversation Optimize Query Line

I currently save with this method:

    $alumno = new Alumno();
    $alumno->user_id = auth()->id();
    $alumno->nombres = $request->nombres;
    $alumno->apellidos = $request->apellidos;
    $alumno->nacionalidad = $request->nacionalidad;
    $alumno->ciudad_id = $request->ciudad_id;
    $alumno->edad = $request->edad;
    $alumno->grado = $request-grado
    $alumno->seccion = $request->seccion;
    $alumno->save();
    return redirect('lista_alumnos')->with('success', 'Registrado con éxito!');

how could I use Alumno:: create (); Knowing that I have the field $alumno->user_id = auth()->id();

Activity icon

Started a new Conversation Default Role For New Users

Applying the spatie permission package, to each new registered user that has a default role.

Default function of creating users:

protected function create(array $data)

{ return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), 'nacimiento' => $data['nacimiento'], 'sexo' => $data['sexo'] ]); }

I tried something like:

$user = User::latest('id')->first();

$user->hasRole('visita');

Mar
07
5 months ago
Activity icon

Replied to Eloquent Does Not Relate Model

@tisuchi SQLSTATE[42S22]: Column not found: 1054 Unknown column 'regions.ciudad_id' in 'where clause' (SQL: select * from regions where regions.ciudad_id in (1, 2, 3, 4, 5, 6, 7))

All tables your ID are by convection, because it will be the error

Activity icon

Replied to Eloquent Does Not Relate Model

@tisuchi It doesn't let me access the relationship, it seems that something is wrong; Message: Property [region] does not exist on this collection instance.

Activity icon

Started a new Conversation Eloquent Does Not Relate Model

Model Region

class Region extends Model { protected $fillable = [

    'nombre_region'
];

public function ciudad()
{
    return $this->belongsTo(Ciudad::class);
}

}

Model Ciudad

class Ciudad extends Model { protected $fillable = [

    'region_id','nombre_ciudad'
];

public function regions()
{
    return $this->hasMany(Region::class);
}

}

$ciudadeslista = Ciudad::all();

dd($ciudadeslista->regions->nombre_region);

Property [region] does not exist on this collection instance.