m4martie

m4martie

Member Since 6 Months Ago

Experience Points 1,990
Experience Level 1

3,010 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 12
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

16 Mar
1 week ago

m4martie left a reply on How To Sum Values Of Duplicate ID's

• ActivityPoint • Points

m4martie left a reply on How To Sum Values Of Duplicate ID's

Route

Route::prefix('reports')->group(function () {
        Route::get('index', '[email protected]')->name('reports');

        // //View Activity
        // Route::post('activity/{activity}', '[email protected]')->name('report.activity');

        Route::get('{activity}', '[email protected]')->name('report.activity');

    });

[email protected]

public function attendance(Activity $activity, Organization $organization)
    {


        $reports = ActivityPoint::where('activity_id', $activity->id)->get();

        $points = ActivityPoint::where('points', '$reports->points')->sum('points');

        $organizations = Organization::all();
        $activities = Activity::all();
        $officers = Officer::where('organization_id', $organization->id)->get();

        return view('reports.activity', compact('organization', 'activity', 'reports', 'organizations', 'activities', 'officers', 'points'));
    }

activity.blade.php

<table class="ui unstackable compact celled table">
        <thead>
            <th class="center aligned">Points</th>
            <th class="center aligned">Full Name</th>
            <th class="center aligned">Organization Name</th>
            <th class="center aligned">Position</th>
            <th class="center aligned">Activity Name</th>
            <th class="center aligned">Total</th>
        </thead>
        <tbody>
            @foreach($reports as $report)
            <tr>
                <td class="center aligned"><b>{{ $report->points }}</b></td>
                <td class="center aligned"><b>{{ $report->user->firstname }} {{ $report->user->lastname }}</b></td>
                <td class="center aligned"><b>{{ $report->organization->name }}</b></td>
                @foreach($report->user->officers as $officer)
                <td class="center aligned">{{ $officer->position }}</td>
                @endforeach
                <td class="center aligned"><b>{{ $report->activity->name }}</b></th>
                <td class="center aligned"><b>{{ $points }}</b></th>
            </tr>
            @endforeach
        </tbody>
    </table>

well, I'm just working on how to place every data into the table, but yeah that's all. And what I want to get is both all users and individual total of the points they earned to the activity

15 Mar
1 week ago

m4martie left a reply on How To Sum Values Of Duplicate ID's

@richard so if I want individual collection I'll just $user = App\User::findOrFail(id_of_that_particular_user);???

m4martie left a reply on How To Sum Values Of Duplicate ID's

@richard can it be done both? because I need collecting of users and individually.

m4martie left a reply on How To Sum Values Of Duplicate ID's

@gorakhyadav same as you man, I just only receiving "0" value

m4martie left a reply on How To Sum Values Of Duplicate ID's

@BOBBYBOUWMANN - @bobbybouwmann I already did this man but it is still giving me a "0" value. Or any ways you can teach me to make it more accurate to sum data?

14 Mar
1 week ago

m4martie started a new conversation How To Sum Values Of Duplicate ID's

I have the same user_id's with different and I want to compute the total points of that particular user. And this is what I did but I'm getting errors and/or just "0"

Controller

$points = ActivityPoint::where('points', '$reports->points')->sum('points');

And how I call to .blade

{{ $points }}

Need help for this, thank you in advance.

07 Mar
2 weeks ago

m4martie left a reply on Undefined URL Value

@TYKUS - yeah, probably it's because of the js, can you suggest a better way for this thing, I'm just willing to learn someways since then

m4martie left a reply on Undefined URL Value

@CRONIX - yeah, I've been using vue.js for this, and somewhat thinking to change it to pure php

m4martie left a reply on Undefined URL Value

Controller

public function add_student(MyClass $my_class)
    {

        $role = Role::where('name', 'shs-student')->first();
        $students = $role->users;

        $users = User::withTrashed()->get();

        return view('my_class.add_student', compact('my_class', 'students', 'users'));
    }
public function list(MyClass $my_class)
        {

            // print_r($my_class);
            // die();
            
            return response()->json($my_class);
        }

Route

Route::get('view/add-student/{my_class}','[email protected]_student')->name('my_class.add_student');
Route::get('list', '[email protected]')->name('my_class.list');

Blade

<a :href="'add-student/' + my_class.id" class="ui mini green icon button"><i class="plus icon"></i>

Vue.js

getMy_Class(){
            axios.get('{{ route('my_class.list', $my_class->id) }}')
            .then(response => {
                this.my_class = response.data;
            })
            .catch(error => {
                console.log(error.response.data);
            });
        },

m4martie started a new conversation Undefined URL Value

Hello, I'm developing a project, which I stumbled upon to an error that every time view button of my page I come up with this error

http://localhost/system/public/my_classes/view/add-student/undefined

And I don't know how to fix this problem can someone help me, I don't think there's a problem to my Controller, Blade or Routing. I'm confused. Help me.

18 Nov
4 months ago

m4martie left a reply on How To Call Value From BelongsTo Relationship To HasMany

@lostdreamer_nl I already pass my_classes variable to view

public function index()
        {
            $strands = Strand::all();
            $sections = Section::all();
            $grade_levels = GradeLevel::all();
            $semesters = Semester::all();
            $school_years = SchoolYear::all();
            
            $my_classes = MyClass::withTrashed()->get();

            return view('my_classes.index', compact('my_classes', 'strands', 'sections', 'grade_levels', 'semesters', 'school_years'));

        }
17 Nov
4 months ago

m4martie left a reply on How To Call Value From BelongsTo Relationship To HasMany

And I got this kind of error

Invalid argument supplied for foreach() (View: C:\xampp\htdocs\system\resources\views\my_classes\index.blade.php)

m4martie left a reply on How To Call Value From BelongsTo Relationship To HasMany

index.blade.php

@foreach($my_classes as $my_class)
        <tr v-for="">
            <td class="center aligned">{{ $my_class->id }}</td>
            @foreach($my_class->strands as $strand)
            <td class="center aligned">{{ $strand->name }}</td>
            @endforeach 
@endfo

here's my view

m4martie started a new conversation How To Call Value From BelongsTo Relationship To HasMany

MyClass.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\SoftDeletes;

class MyClass extends Model
{
    use Notifiable;
    use SoftDeletes;
    
    protected $fillable = [
        'strand_id', 'section_id', 'grade_level_id', 'semester_id', 'school_year_id',
    ];

    protected $dates = ['deleted_at'];

    public function student()
    {
        return $this->belongsToMany('App\User')();
    }

    public function strand()
    {
        return $this->belongsTo('App\Strand');
    }

    public function section()
    {
        return $this->belongsTo('App\Section');
    }

    public function gradelevel()
    {
        return $this->belongsTo('App\GradeLevel');
    }

    public function semester()
    {
        return $this->belongsTo('App\Semester');
    }

    public function schoolyear()
    {
        return $this->belongsTo('App\SchoolYear');
    }

}

Strand.php

public function myclass()
    {
        return $this->hasMany('App\MyClass')();
    }

and every time I call foreach to my_classes/index.blade.php like this

@foreach($my_classes as $my_class)
        <tr v-for="">
            <td class="center aligned">{{ $my_class->id }}</td>
            @foreach($my_class->strands as $strand)   
            <td class="center aligned">{{ $strand->name }}</td>
            @endforeach
            <td class="center aligned">{{ $my_class->section_id }}</td>
            <td class="center aligned">{{ $my_class->grade_level_id }}</td>
            <td class="center aligned">{{ $my_class->semester_id }}</td>
            <td class="center aligned">{{ $my_class->school_year_id }}</td>               
            <td class="center aligned">
                <div class="centered extra centered">
                    <div>
                    @if($my_class->deleted_at == null)
                        <a href="" class="ui mini primary icon button"><i class="eye icon"></i> View</a>
                        <a href="" class="ui mini teal icon button"><i class="edit icon"></i> Update</a>
                        <button class="ui mini red icon button" onclick="confirmation({{ $my_class->id }})"><i class="trash icon"></i> Delete</button>
                    </div>
                    @else
                    <div>
                        <button class="ui mini green icon button" onclick="restoration({{ $my_class->id }})"><i class="undo icon"></i>Restore</button>
                    </div>
                    @endif
                </div>
            </td>
        </tr>
        @endforeach

I have error, like undefined variable.

15 Nov
4 months ago

m4martie left a reply on How To Reset Dropdown In Vue.js

<div class="field">
            <label>Role</label>
            <div class="ui left icon input">
                <select name="roles[]" id="roles" class="ui fluid dropdown" v-model="newuser.roles" multiple>
                    <option v-for="role in options.roles" v-bind:value="role.id" v-text="role.display_name"></option>
                </select>
            </div>
        </div>
        <div class="field">
            <label>Permission</label>
            <div class="ui left icon input">
                <select name="permissions[]" id="permissions" class="ui fluid dropdown" v-model="newuser.permissions" multiple>
                    <option v-for="permission in options.permissions" v-bind:value="permission.id" v-text="permission.display_name"></option>
                </select>
            </div>
        </div>

Here my dropdown menu

m4martie started a new conversation How To Reset Dropdown In Vue.js

I'm working on vue.js and I'm newbie, is there a way to reset a dropdown in my form?

11 Oct
5 months ago

m4martie started a new conversation Semantic UI Form Validator

Uhm, currently working on a project, and I am using semantic ui, in my log in form I want to message or validate the user if he/she entered the correct credentials or incorrect.

04 Oct
5 months ago

m4martie left a reply on How To Limit User Access Via If Else

And at this point I'm creating a User with a President role and has a permission of delete_user but still the button is not disabled.

m4martie started a new conversation How To Limit User Access Via If Else

I'm currently working with my permissions to my user and with their roles, and I cannot get what I want. Here my code

PermissionsTablesSeeder

$add_user = Permission::create([
            'name' => 'add-user',
            'display_name' => 'Add user',
            'description' => 'Allows user to add new users',
        ]);

        $update_user = Permission::create([
            'name' => 'update-user',
            'display_name' => 'Update user',
            'description' => 'Allows user to update users',
        ]);

        $delete_user = Permission::create([
            'name' => 'delete-user',
            'display_name' => 'Delete user',
            'description' => 'Allows user to Delete users',
        ]);

RolesTablesSeeder

$permission = Permission::all();

        $role = Role::create([
            'name' => 'administrator',
            'display_name' => 'Administrator',
            'description' => 'System Administrator',
        ]);

        $role->permissions()->attach($permission);

        $role = Role::create([
            'name' => 'organizations-president',
            'display_name' => 'President',
            'description' => 'Can add, update, and delete members',
        ]);

        $role->permissions()->attach($add_user);
        $role->permissions()->attach($update_user);
        $role->permissions()->attach($delete_user);

UsersTablesSeeder

$admin = Role::where('name', 'administrator')->first();
        $permission = Permission::all();

        $user = User::create([
        'id_number' => '0477-16',
        'firstname' => 'John',
        'lastname' => 'Advincula',
        'username' => 'tin',
        'email' => '[email protected]',
        'password' => bcrypt('19981205'),
        ]);

        $user->roles()->attach($admin);
        $user->permissions()->attach($permission);

        $admin = Role::where('name', 'administrator')->first();
        $permission = Permission::all();

        $user = User::create([
        'id_number' => '0331-16',
        'firstname' => 'Ivy Grace',
        'lastname' => 'Tingal',
        'username' => 'igt',
        'email' => '[email protected]',
        'password' => bcrypt('19990210'),
        ]);

        $user->roles()->attach($admin);
        $user->permissions()->attach($permission);

My IF ELSE Statement in my users/index.blade.php

@if(auth()->user()->can('add_user'))
        <div class="field">
            <button type="submit" class="ui animated fade fluid primary icon button">
                <div class="visible content">Add User</div>
                <div class="hidden content"><i class="ion-person-add icon"></i></div>
            </button>
        </div>
        @else
        <div class="field">
            <button type="submit" class="ui disabled animated fade fluid primary icon button">
                <div class="visible content">Add User</div>
                <div class="hidden content"><i class="ion-person-add icon"></i></div>
            </button>
        </div>
        @endif
25 Sep
5 months ago

m4martie left a reply on How To Add Role_id To User Table

well thank you very much it's working fine now.

m4martie left a reply on How To Add Role_id To User Table

then it directly stored to role_user table?

m4martie left a reply on How To Add Role_id To User Table

<div class="field">
            <div class="ui left icon input">
                <select class="ui fluid dropdown">
                <option value="">Role</option>
                    @foreach($roles as $roles)
                    <option value="{{ $roles->id }}">{{ $roles->display_name }}</option>
                    @endforeach
                </select>
            </div>
         </div>

through selection

m4martie left a reply on How To Add Role_id To User Table

I see. Do I need to create any pivot table?

m4martie left a reply on How To Add Role_id To User Table

I have data in my role table, it is just I don't know how to store it

m4martie left a reply on How To Add Role_id To User Table

Yeah I already created role_user_table but the thing is I don't know on how to store the role_id from it.

m4martie left a reply on How To Add Role_id To User Table

My Role Model

class Role extends Model
{

    use SoftDeletes;

    protected $fillable = [
        'name', 'display_name', 'description',
    ];

    protected $dates = ['deleted_at'];
    
    public function users()
    {
        return $this->belongsToMany(User::class);
    }

    public function permissions()
    {
        return $this->belongsToMany(Permission::class);
    }

RoleController

class RoleController extends Controller
{
    public function index()
        {
            $roles = Role::all();

            return view('roles.index', compact('roles'));

        }

    public function store(Request $request)
        {

            $role = Role::create([

            'name' => $request->name,
            'display_name' => ucwords($request->display_name),
            'description' => $request->description,

            ]);

            //return response()->json("New Student Added", 200);
            Session::flash('success_message', "New Role Added");
            return Redirect::back();
        }

    // Deleting a Role
    // Handles Route::get('delete/{role}', '[email protected]')->name('role.delete');
    public function delete(Role $role){
        $role->delete();
        return response()->json("Role Deleted");
    }

    public function restore($id)
    {
        $role = Role::withTrashed()->where('id', $id)->first();
        $role->restore();

        Session::flash('success_message', "Role Restored");
        return Redirect()->back();
    }

User Model

class User extends Authenticatable
{
    use Notifiable;
    use SoftDeletes;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'firstname', 'lastname', 'username', 'email', 'password', 'role_id',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function student()
    {
        return $this->hasMany(Student::class)->latest();
    }

    public function permissions()
    {
        return $this->belongsToMany(Permission::class);
    }

    public function roles()
    {
        return $this->belongsToMany(Role::class);
    }

UserController

class UserController extends Controller
{
    public function index()
    {
        $users = User::withTrashed()->get();

        return view('users.index', compact('users'));
    }

    public function store(Request $request)
    {
        $user = User::create
        ([
            'firstname' => ucwords($request->firstname),
            'lastname' => ucwords($request->lastname),
            'username' => $request->username,
            'email' => $request->username,
            'password' => bcrypt($request->password),
        ]);

        //return response()->json("New User Added", 200);
        Session::flash('success_message', "New User Added");
        return Redirect::back();
    }

    public function delete(User $user)
    {
        $user->delete();
        return response()->json("User Deleted");
    }

    public function restore($id)
    {
        $user = User::withTrashed()->where('id', $id)->first();
        $user->restore();

        Session::flash('success_message', "User Restored");
        return Redirect()->back();

    }

}

and I don't know why on how to add the role in my user upon registering.

m4martie started a new conversation How To Add Role_id To User Table

Hi, I'm new to laravel and stuck with this concept, should I make a pivot table or just lack some proper coding?

18 Sep
6 months ago

m4martie left a reply on How To Set Default Value When Storing A Data

ohhh tinyint it is? because I put

$table->string('row_status')->default(1);

to my migration

m4martie left a reply on How To Set Default Value When Storing A Data

public function store(Request $request)
                {

                    $user = User::create([
                    'firstname' = $request->firstname,
                    'lastname' = $request->lastname,
                    'username' = $request->username,
                    'email' = $request->email,
                    'password' = bcrypt($request->password),
                    'row_status' => '1';
                    ]);

                    return redirect('/home')

                }

here's my RegisterController

m4martie started a new conversation How To Set Default Value When Storing A Data

Hello, I'm new to laravel, can I ask if how to set a default value when storing a data?

25 Aug
6 months ago

m4martie left a reply on How To Retrieve User

Thanks guys, I can finally move on my project. It's working now.

m4martie left a reply on How To Retrieve User

@cronix this is my web. php

m4martie left a reply on How To Retrieve User

@Cronix Yes, that's the one I need to figure out on how to use that one.

m4martie left a reply on How To Retrieve User

@Cronix there's no error at all because I didn't put any routes yet at web.php It just kept redirecting to /login

m4martie left a reply on How To Retrieve User

@Cronix yes it changed the session data.

m4martie left a reply on How To Retrieve User

@Cronix I checked the sessions and there's a file generated

a:5:{s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}s:6:"_token";s:40:"IBcHQRsnm3luvrNhBuCHuKE9MzghvrA0ck6KSSbX";s:9:"_previous";a:1:{s:3:"url";s:26:"http://127.0.0.1:8000/home";}s:3:"url";a:1:{s:8:"intended";s:27:"http://127.0.0.1:8000/login";}s:50:"login_web_59ba36addc2b2f9401580f014c7f58ea4e30989d";i:4;}

m4martie left a reply on How To Retrieve User

@Cronix They can't log in via log in form. Sorry for bad description. And yes I am using auth form

m4martie left a reply on How To Retrieve User

@crnkovic Thanks I'm doing it right now.

m4martie left a reply on How To Retrieve User

They can't log in via log in form. Sorry for bad description.

m4martie started a new conversation How To Retrieve User

Hello guys, I'm new here, as well as to Laravel, and I am currently developing a system. And I have this difficulty that I don't know how to log in my currently registered user. If you can help, that is a big help for me.