MarkMatute

MarkMatute

Member Since 4 Years Ago

Bulacan - Malolos City

at Student

Experience Points 2,625
Experience Level 1

2,375 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 5
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

23 Jul
4 years ago

MarkMatute left a reply on Can't Laracast Be Free? :(

Sorry for this. Thanks for you thoughts.

MarkMatute started a new conversation Can't Laracast Be Free? :(

It's so hard to think that theres a great site like laracasts but theres nothing i can do, i dont even have a card :(

17 Jul
4 years ago

MarkMatute left a reply on Linking To CSS And JS Laravel 5.1

@mdobrenko ,

    <link rel="stylesheet" type="text/css" href="{{asset('css/yourcss.css')}}"/>    

assuming that you have your css folder inside your public directory, i think you need to require illuminate/html to you project.

MarkMatute left a reply on TokenMismatchException

@Kryptonit3 ,@opheliadesign youre correct is an expired session, but i encounter this the moment i start my website, cant it self regenerate everytime site opens?

MarkMatute left a reply on TokenMismatchException

I figured it out though :) everytime i ran into this problem i do this ''' get('regentoken',function(){ return csrf_token(); }); ''' but i dont know what would be a good long term solution

15 Jul
4 years ago

MarkMatute started a new conversation Polymophic OnDelete Cascade

How can i delete async.

MarkMatute left a reply on TokenMismatchException

@opheliadesign its happening on login, every time i start the project some times it says this error upon login TokenMismatchException in VerifyCsrfToken.php line 53:

MarkMatute started a new conversation TokenMismatchException

TokenMismatchException occurs only sometimes, works on Mozilla not in Chrome

14 Jul
4 years ago

MarkMatute left a reply on Old Password Validation

@bashy, its for updating the user profile password before changing it in the database the user must confirm his old password before saving the new one , but i dont know how to validate that.

MarkMatute left a reply on Old Password Validation

@JarekTkaczyk oh i see, thanks man but how can i pass password params in here

if (Hash::check($plainPassword, $hashedPassword) {
    // valid
}


 $validator = Validator::make($request->all(),[
            "firstname"=>"required",
            "lastname"=>"required",
            "username"=>"required|unique:users,username,".$employee->id,
            "current_password"=>"min:8|old_password(params)", //This dude
            "phonenumber"=>"required",
            "email"=>"required|unique:employees,email,".$employee->id,
            "filePhoto"=>"mimes:jpeg,bmp,png"
        ]);

MarkMatute left a reply on Old Password Validation

@JarekTkaczyk what i mean is this,

 $validator = Validator::make($request->all(),[
            "firstname"=>"required",
            "lastname"=>"required",
            "username"=>"required|unique:users,username,".$employee->id,
            "current_password"=>"min:8|old_password",
            "phonenumber"=>"required",
            "email"=>"required|unique:employees,email,".$employee->id,
            "filePhoto"=>"mimes:jpeg,bmp,png"
        ]);

MarkMatute started a new conversation Old Password Validation

Can you please help me out on this, i need my form to validate if form field is equal to current password

MarkMatute left a reply on Does AngularJS Mix Well With L5? Any Suggestions?

@AnneFisher84 what i mean is, what could be the best partner in developing in Laravel 5 :)

MarkMatute started a new conversation Does AngularJS Mix Well With L5? Any Suggestions?

How can i boost Laravel5.1 :)

11 Jul
4 years ago

MarkMatute left a reply on Laravel Upload FIle With AJAX Not Working

@StuffedGoat there is no error really, the problem was the file is not present at the request if i submiited the form with ajax.

MarkMatute started a new conversation Laravel Upload FIle With AJAX Not Working

I tried submitting the form with non ajax request and it works, but in an ajax requested form the file was not inside the request heres my form

{!! Form::open(['id'=>'saveEmployeeForm','files'=>true]) !!}
                            <div class="box-body">
                            <h4>Account Details</h4>
                            <div class="row">
                                <div class="col-lg-4 col-md-4">
                                    <img src="{{asset('images/employees/default.jpg')}}" class="employee-profile-image img-responsive img-thumbnail" id="previewHolder">
                                    <!--File Photo-->
                                    <div class="form-group">
                                        <label for="filePhoto">File Photo:</label>
                                         {!! Form::file('filePhoto',['class'=>'form-control borrowerImageFile','id'=>'filePhoto']) !!}
                                    </div>
                                    <!-- END OF File Photo-->
                                </div>
                                <div class="col-lg-8 col-md-8">
                                    <!--Username-->
                                    <div class="form-group col-lg-12">
                                        <label for="username">Username:</label>
                                        {!! Form::text('username',null,['class'=>'form-control','id'=>'username']) !!}
                                    </div>
                                    <!-- END OF Username-->
                                    <!--Password-->
                                    <div class="form-group col-lg-12">
                                        <label for="password">Password:</label>
                                        {!! Form::input('password','password',null,['class'=>'form-control','id'=>'password']) !!}
                                    </div>
                                    <!-- END OF Password-->
                                    <!--Confirm Password-->
                                    <div class="form-group col-lg-12">
                                        <label for="password_confirmation">Confirm Password:</label>
                                        {!! Form::input('password','password_confirmation',null,['class'=>'form-control','id'=>'password_confirmation']) !!}
                                    </div>
                                    <!-- END OF Confirm Password-->
                                </div>
                            </div>
                            <hr/>
                            <h4>Personal Details</h4>
                                {{--//NAMES--}}
                                <div class="row">
                                     <!--First Name-->
                                     <div class="form-group col-lg-6">
                                         <label for="firstname">First Name:</label>
                                         {!! Form::text('firstname',null,['class'=>'form-control','id'=>'firstname']) !!}
                                     </div>
                                     <!-- END OF First Name-->
                                     <!--Last Name-->
                                     <div class="form-group col-lg-6">
                                         <label for="lastname">Last Name:</label>
                                         {!! Form::text('lastname',null,['class'=>'form-control','id'=>'lastname']) !!}
                                     </div>
                                     <!-- END OF Last Name-->
                                 </div>
                                  {{--//CONTACTS--}}
                                  <div class="row">
                                        <!--Phone Number-->
                                        <div class="form-group col-lg-6">
                                            <label for="phonenumber">Phone Number:</label>
                                            {!! Form::text('phonenumber',null,['class'=>'form-control','id'=>'phonenumber']) !!}
                                        </div>
                                        <!-- END OF Phone Number-->
                                        <!--Emai-->
                                        <div class="form-group col-lg-6">
                                            <label for="email">Email:</label>
                                            {!! Form::text('email',null,['class'=>'form-control','id'=>'email']) !!}
                                        </div>
                                        <!-- END OF Emai-->
                                  </div>
                                  {{--//ADDRESS LINE--}}
                                  <div class="row">
                                        <!--Address 1-->
                                        <div class="form-group col-lg-6">
                                            <label for="address1">Address 1:</label>
                                            {!! Form::text('address_1',null,['class'=>'form-control']) !!}
                                        </div>
                                        <!-- END OF Address 1-->
                                        <!--Address 2-->
                                        <div class="form-group col-lg-6">
                                            <label for="address2">Address 2:</label>
                                            {!! Form::text('address_2',null,['class'=>'form-control']) !!}
                                        </div>
                                        <!-- END OF Address 2-->
                                  </div>

                                  {{--CITY / STATE--}}
                                  <div class="row">
                                       <!--City-->
                                       <div class="form-group col-lg-6">
                                           <label for="city">City:</label>
                                           {!! Form::text('city',null,['class'=>'form-control']) !!}
                                       </div>
                                       <!-- END OF City-->

                                       <!--State/Province-->
                                       <div class="form-group col-lg-6">
                                           <label for="province">State/Province:</label>
                                           {!! Form::text('province',null,['class'=>'form-control']) !!}
                                       </div>
                                       <!-- END OF State/Province-->
                                  </div>

                                  {{--ZIP / COUNTRY--}}
                                  <div class="row">
                                       <!--Zip-->
                                       <div class="form-group col-lg-6">
                                           <label for="zip">Zip:</label>
                                           {!! Form::text('zip',null,['class'=>'form-control']) !!}
                                       </div>
                                       <!-- END OF Zip-->
                                       <!--country-->
                                       <div class="form-group col-lg-6">
                                           <label for="country">Country:</label>
                                           {!! Form::text('country',null,['class'=>'form-control']) !!}
                                       </div>
                                       <!-- END OF country-->
                                  </div>

                                  <div class="row">
                                       <div class="form-group col-lg-12">
                                            <label for="comment">Comment:</label>
                                            {!! Form::textarea('comments',null,['class'=>'form-control']) !!}
                                       </div>
                                  </div>

                                 <div class="box-footer">
                                     <div class="col-lg-3">
                                          {!! Form::submit('Save Employee',['class'=>'btn btn-success']) !!}
                                     </div>
                                     @include('admin.partials.loading')
                                 </div>
                            </div>
                {!! Form::open(['id'=>'saveEmployeeForm','files'=>true]) !!}
                            <div class="box-body">
                            <h4>Account Details</h4>
                            <div class="row">
                                <div class="col-lg-4 col-md-4">
                                    <img src="{{asset('images/employees/default.jpg')}}" class="employee-profile-image img-responsive img-thumbnail" id="previewHolder">
                                    <!--File Photo-->
                                    <div class="form-group">
                                        <label for="filePhoto">File Photo:</label>
                                         {!! Form::file('filePhoto',['class'=>'form-control borrowerImageFile','id'=>'filePhoto']) !!}
                                    </div>
                                    <!-- END OF File Photo-->
                                </div>
                                <div class="col-lg-8 col-md-8">
                                    <!--Username-->
                                    <div class="form-group col-lg-12">
                                        <label for="username">Username:</label>
                                        {!! Form::text('username',null,['class'=>'form-control','id'=>'username']) !!}
                                    </div>
                                    <!-- END OF Username-->
                                    <!--Password-->
                                    <div class="form-group col-lg-12">
                                        <label for="password">Password:</label>
                                        {!! Form::input('password','password',null,['class'=>'form-control','id'=>'password']) !!}
                                    </div>
                                    <!-- END OF Password-->
                                    <!--Confirm Password-->
                                    <div class="form-group col-lg-12">
                                        <label for="password_confirmation">Confirm Password:</label>
                                        {!! Form::input('password','password_confirmation',null,['class'=>'form-control','id'=>'password_confirmation']) !!}
                                    </div>
                                    <!-- END OF Confirm Password-->
                                </div>
                            </div>
                            <hr/>
                            <h4>Personal Details</h4>
                                {{--//NAMES--}}
                                <div class="row">
                                     <!--First Name-->
                                     <div class="form-group col-lg-6">
                                         <label for="firstname">First Name:</label>
                                         {!! Form::text('firstname',null,['class'=>'form-control','id'=>'firstname']) !!}
                                     </div>
                                     <!-- END OF First Name-->
                                     <!--Last Name-->
                                     <div class="form-group col-lg-6">
                                         <label for="lastname">Last Name:</label>
                                         {!! Form::text('lastname',null,['class'=>'form-control','id'=>'lastname']) !!}
                                     </div>
                                     <!-- END OF Last Name-->
                                 </div>
                                  {{--//CONTACTS--}}
                                  <div class="row">
                                        <!--Phone Number-->
                                        <div class="form-group col-lg-6">
                                            <label for="phonenumber">Phone Number:</label>
                                            {!! Form::text('phonenumber',null,['class'=>'form-control','id'=>'phonenumber']) !!}
                                        </div>
                                        <!-- END OF Phone Number-->
                                        <!--Emai-->
                                        <div class="form-group col-lg-6">
                                            <label for="email">Email:</label>
                                            {!! Form::text('email',null,['class'=>'form-control','id'=>'email']) !!}
                                        </div>
                                        <!-- END OF Emai-->
                                  </div>
                                  {{--//ADDRESS LINE--}}
                                  <div class="row">
                                        <!--Address 1-->
                                        <div class="form-group col-lg-6">
                                            <label for="address1">Address 1:</label>
                                            {!! Form::text('address_1',null,['class'=>'form-control']) !!}
                                        </div>
                                        <!-- END OF Address 1-->
                                        <!--Address 2-->
                                        <div class="form-group col-lg-6">
                                            <label for="address2">Address 2:</label>
                                            {!! Form::text('address_2',null,['class'=>'form-control']) !!}
                                        </div>
                                        <!-- END OF Address 2-->
                                  </div>

                                  {{--CITY / STATE--}}
                                  <div class="row">
                                       <!--City-->
                                       <div class="form-group col-lg-6">
                                           <label for="city">City:</label>
                                           {!! Form::text('city',null,['class'=>'form-control']) !!}
                                       </div>
                                       <!-- END OF City-->

                                       <!--State/Province-->
                                       <div class="form-group col-lg-6">
                                           <label for="province">State/Province:</label>
                                           {!! Form::text('province',null,['class'=>'form-control']) !!}
                                       </div>
                                       <!-- END OF State/Province-->
                                  </div>

                                  {{--ZIP / COUNTRY--}}
                                  <div class="row">
                                       <!--Zip-->
                                       <div class="form-group col-lg-6">
                                           <label for="zip">Zip:</label>
                                           {!! Form::text('zip',null,['class'=>'form-control']) !!}
                                       </div>
                                       <!-- END OF Zip-->
                                       <!--country-->
                                       <div class="form-group col-lg-6">
                                           <label for="country">Country:</label>
                                           {!! Form::text('country',null,['class'=>'form-control']) !!}
                                       </div>
                                       <!-- END OF country-->
                                  </div>

                                  <div class="row">
                                       <div class="form-group col-lg-12">
                                            <label for="comment">Comment:</label>
                                            {!! Form::textarea('comments',null,['class'=>'form-control']) !!}
                                       </div>
                                  </div>

                                 <div class="box-footer">
                                     <div class="col-lg-3">
                                          {!! Form::submit('Save Employee',['class'=>'btn btn-success']) !!}
                                     </div>
                                     @include('admin.partials.loading')
                                 </div>
                            </div>
                       {{--</form>--}}
                       {!! Form::close() !!}

and my controller

  public function store(Request $request)
    {
        $validator = Validator::make($request->all(),[
            "firstname"=>"required",
            "lastname"=>"required",
            "username"=>"required|unique:users",
            "password"=>"required|min:8|confirmed",
            "phonenumber"=>"required",
            "email"=>"required|unique:employees",
            "filePhoto"=>"required"
        ]);

        if($validator->fails()){
            return response(['valid'=>false,'errors'=>$validator->errors()]);
        }

        $userdata = $request->all();
        $userdata = array_add($userdata,'permission_id','1');
        $acode = str_replace('/',"*",bcrypt($request->input('email')));
        $userdata = array_add($userdata,'code',$acode);

        Employee::create($request->all())->user()->save(new User($userdata));
        $employee = new Employee($request->all());

        //Send Confirmation Email
        Mail::send('emails.employee_confirmation',['employees'=>$employee,'acode'=>$acode], function ($message) use ($employee) {
            $message->from('markernest.matute@gmail.com', 'YML Gen. Merch.');
            $message->to($employee->email)->cc('markernest.matute@gmail.com');
        });
        return response(['valid'=>true]);
    }

HELP ME PLEASE

08 Jul
4 years ago

MarkMatute left a reply on Laravel And AJAX

@phildawson im getting MethodNotAllowedException. Some times it saves but after that nothing is saved again.

MarkMatute left a reply on Laravel And AJAX

@phildawson that helped, but still i cant save the Employee i dont know why, but ist saying Error 500.

MarkMatute left a reply on Laravel And AJAX

@phildawson if i change 'store' to 'employees/store' im getting this error http://localhost:8000/employees/employees/store 404 (Not Found), because it must be 'employees/store' only, my main problem was can't store the validaten employee.

MarkMatute started a new conversation Laravel And AJAX

I cant save my data, is returning error 500, AJAX Code

public function store(Request $request)
    {
        $validator = Validator::make($request->all(),[
            "firstname"=>"required",
            "lastname"=>"required",
            "username"=>"required|unique:users",
            "password"=>"required|min:8|confirmed"
        ]);

        if($validator->fails()){
            return response(['valid'=>false,'errors'=>$validator->errors()]);
        }

        if(Employee::create($request->all())){
            return response::json(array(
                'valid'=>true
            ));
        }
    }

My Request

    $("#saveEmployeeForm").submit(function(e){
        e.preventDefault();
        $("#saveEmployeeForm .form-group").removeClass("has-error");
        var formData = $(this).serialize();

        $.ajax({
            beforSend:function(){

            },
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            url:"store",
            type:"POST",
            data:formData,
            success: function(data){
                if(!data.valid){
                    var keys = Object.keys(data.errors);
                    $.each(keys,function(index,value){
                        setErrorToField("#"+value);
                    });
                }else{
                    console.log(data);
                }
            },
            complete: function(){

            },
            error: function(err){
                console.log(err);
            }
        });
    });
05 Jul
4 years ago

MarkMatute left a reply on Laravel Login With AJAX

@slick i cant send my ajax request, im getting errors, POST http://localhost:8000/auth/auth/login 500 (Internal Server Error) and this is my code ''' $(document).ready(function(){

var loginForm = $("#loginForm");
loginForm.submit(function(e){
    e.preventDefault();
    var formData = loginForm.serialize();

    $.ajax({
        url:'auth/login',
        type:'POST',
        data:formData,
        success:function(data){
            console.log(data);
        },
        error: function (data) {
            console.log(data);
        }
    });
});

alert('Successfully Loaded');

});

'''

MarkMatute started a new conversation Laravel Login With AJAX

How can i properly integrate an ajax login with Laravel? Can i use AngularJS for this?

18 Jun
4 years ago

MarkMatute started a new conversation Reverse Engineering, Larabook

<?php namespace Larabook\Users;

trait FollowableTrait {

    /**
     * Get the list of users that the current user follows.
     *
     * @return mixed
     */
    public function followedUsers()
    {
        return $this->belongsToMany(static::class, 'follows', 'follower_id', 'followed_id')->withTimestamps();
    }

    /**
     * Get the list of users who follow the current user.
     *
     * @return mixed
     */
    public function followers()
    {
            return $this->belongsToMany(static::class, 'follows', 'followed_id', 'follower_id')->withTimestamps();
        }

    /**
     * Determine if current user follows another user.
     *
     * @param User $otherUser
     * @return bool
     */
    public function isFollowedBy(User $otherUser)
    {
        $idsWhoOtherUserFollows = $otherUser->followedUsers()->lists('followed_id');

        return in_array($this->id, $idsWhoOtherUserFollows);
    }

}

Why is there no hasMany, and there are 2 belongToMany?

MarkMatute left a reply on Laravel 5.1 For Online POS + Ecommerce Shop

The system is intented for a Hardware Store, its just a tiny store :D Features of it are just typical Cashier + Admin then product listing,purchasing and then reciept,the e-shop is also a typical shop, my problem was i dont know where to start in developing my thesis, its much like a junior version of VEND. can you please give me a clue here :D

MarkMatute started a new conversation Laravel 5.1 For Online POS + Ecommerce Shop

I will be working on my thesis soon, an Online POS System with E-Shop, is Laravel 5.1 the answer to my thesis? :)

MarkMatute left a reply on Laravel 4 From Scratch Or Laravel 5 Fundamentals

@bobbybouwmann (y) thanks for that correction. Its Laravel 5.1, thats what i mean :D

MarkMatute left a reply on Laravel 4 From Scratch Or Laravel 5 Fundamentals

Laravel 5, because its now on LTS

16 Jun
4 years ago

MarkMatute left a reply on Event Generators

Thanks, but i copied this line of code to

protected $listen = [
    'App\Events\PodcastWasPurchased' => [
        'App\Listeners\EmailPurchaseConfirmation',
    ],
]

the EventsServiceProvider but still on Events and LKisteners SomeEvent and EventListener was generated.

MarkMatute started a new conversation Event Generators

My problem is how can i generate my event, if i run php artisan event:generate, It Generates 'SomeEvent' file, For example i want to generate an event 'UserHasLikedAPost' event with php artisan event:generate

14 Jun
4 years ago

MarkMatute started a new conversation Events, Jobs,Exceptions,Queues And Services

Im a little bit confused in using this Laravel features.

13 Jun
4 years ago

MarkMatute left a reply on Is There A Better Way?

@Kryptonit3 Thank you so much! :)

MarkMatute left a reply on Is There A Better Way?

This is the contoller for the user

    <?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Support\Facades\Auth;
class UsersController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        $friends= User::where('id','!=',Auth::user()->id)->get();
        return view('users.index',compact('friends'));
    }

    /**
     * @param $id
     * @return \Illuminate\View\View
     */
    public function myfriends($id)
    {
        $friends = User::find($id)->friends()->get();
        return view('users.myfriends',compact('friends'));
    }
    
    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
    public function store()
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function update($id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function destroy($id)
    {
        //
    }


    /**
     * Add id to user_friend pivot
     * @param $id
     */
    public function add($id){
        Auth::user()->friends()->attach($id);
        return redirect('users');
    }


    /**
     * Cancels Friend Request Sent and Recieved
     * @param $id
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     */
    public function cancel($id){
        Auth::user()->friends()->detach($id);
        return redirect('users');
    }

    public function confirm(){
        
    }
}

MarkMatute left a reply on Is There A Better Way?

I am having trouble managing the pivot table, I need to achieve this

if (Me friends with User)
    Unfriend
else
    if(Me send Request to This User)
        Cancel Request
    else if(User Sent Me Request)
        Reject Request
    else
        Add Friend

This i what im trying to di, much like facebook.

MarkMatute left a reply on Is There A Better Way?

Heres My Code, This will determin if Add Friend, Unfriend,Accept or Cancel Request

@extends('pages.dashboard')
    @section('content')
       @if(count($friends)==0)
            <p>No friends</p>
       @else
            @foreach($friends as $u)
                <div class="row">
                    <div class="col-lg-12">
                        <div class="well">
                            <h4>{{$u->name}}</h4>
                            @if(count(Auth::user()->friends)==0)
                                <a href="{{url('users/add/'.$u->id)}}">Add Friend</a>
                            @else
                                @foreach(Auth::user()->friends as $f)
                                    @if($f->id==$u->id)
                                        @if($f->is_friend)
                                            <a>Unfriend</a>
                                        @else
                                            <a href="{{url('users/cancel/'.$u->id)}}">Cancel Request</a>
                                        @endif
                                    @else
                                        <a>Add Friend</a>
                                    @endif
                                @endforeach
                            @endif
                        </div>
                    </div>
                </div>
            @endforeach
       @endif
    @endsection
@stop

This is my User Migration

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password', 60);
            $table->rememberToken();
            $table->timestamps();
        });


        //FRIENDS TABLE
        Schema::create('user_friend', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->integer('friend_id')->unsigned();
            $table->boolean('is_friend')->default(false);
            $table->timestamps();
            $table->foreign('user_id')
                ->references('id')
                ->on('users');
            $table->foreign('friend_id')
                ->references('id')
                ->on('users');
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('user_friend');
        Schema::drop('users');
    }
}

And This is the User Model

    <?php

namespace App;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'users';

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

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = ['password', 'remember_token'];


    /**
     * Gets Articles Related to the User
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function articles()
    {
        return $this->hasMany('App\Article');
    }


    /**
     * Returns Friends of the user
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function friendsOf(){
        return $this->hasMany('App\User','user_friend','user_id','friend_id');
    }

    /**
     * Returns Users friends with user
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function friends(){
        return $this->belongsToMany('App\User','user_friend','friend_id','user_id');
    }
}

MarkMatute left a reply on Is There A Better Way?

Thuis is the User Model

namespace App;

use Illuminate\Auth\Authenticatable; use Illuminate\Database\Eloquent\Model; use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract { use Authenticatable, CanResetPassword;

/**
 * The database table used by the model.
 *
 * @var string
 */
protected $table = 'users';

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

/**
 * The attributes excluded from the model's JSON form.
 *
 * @var array
 */
protected $hidden = ['password', 'remember_token'];


/**
 * Gets Articles Related to the User
 * @return \Illuminate\Database\Eloquent\Relations\HasMany
 */
public function articles()
{
    return $this->hasMany('App\Article');
}


/**
 * Returns Friends of the user
 * @return \Illuminate\Database\Eloquent\Relations\HasMany
 */
public function friendsOf(){
    return $this->hasMany('App\User','user_friend','user_id','friend_id');
}

/**
 * Returns Users friends with user
 * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
 */
public function friends(){
    return $this->belongsToMany('App\User','user_friend','friend_id','user_id');
}

}

MarkMatute left a reply on Is There A Better Way?

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password', 60);
        $table->rememberToken();
        $table->timestamps();
    });


    //FRIENDS TABLE
    Schema::create('user_friend', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('user_id')->unsigned();
        $table->integer('friend_id')->unsigned();
        $table->boolean('is_friend')->default(false);
        $table->timestamps();
        $table->foreign('user_id')
            ->references('id')
            ->on('users');
        $table->foreign('friend_id')
            ->references('id')
            ->on('users');
    });

}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::drop('user_friend');
    Schema::drop('users');
}

}

MarkMatute left a reply on Is There A Better Way?

  @if(count(Auth::user()->friends)==0)
                            <a>Add Friend</a>
                        @else
                            @foreach(Auth::user()->friends as $f)
                                @if($f->id==$u->id)
                                    @if($f->is_friend)
                                        <a>Unfriend</a>
                                    @else
                                        <a>Cancel Request</a>
                                    @endif
                                @else
                                    <a>Add Friend</a>
                                @endif
                            @endforeach
                        @endif

MarkMatute started a new conversation Is There A Better Way?

So i have a friendship system here and this is my code for retrieving all users and defining id Add Friend, Request Sent, or Unfriend @if(count(Auth::user()->friends)==0) Add Friend @else @foreach(Auth::user()->friends as $f) @if($f->id==$u->id) @if($f->is_friend) Unfriend @else Cancel Request @endif @else Add Friend @endif @endforeach @endif

11 Jun
4 years ago

MarkMatute started a new conversation Error Even If .env File Is Configured

PDOException in Connector.php line 49: SQLSTATE[HY000] [1045] Acc�s refus� pour l'utilisateur: 'homestead'@'@localhost' (mot de passe: OUI)

MarkMatute started a new conversation Laravel 5 On Non Envoyer / Forge Hosting

I need to find a way how.. :(

MarkMatute left a reply on Laravel Deployment To A Shared Hosting?

will it work on a free hosting? :) thank for your replies

MarkMatute started a new conversation Laravel Deployment To A Shared Hosting?

Is it possible to upload a laravel project to a shared hosting?

MarkMatute started a new conversation Laravel 5.1 CSRF Dont Match If Form Has File

Im making a form to add an article with an image, if image was set, CSRF token does not match

08 Jun
4 years ago

MarkMatute started a new conversation What Is The Easiest Way To Deploy A Laravel 5 Project? :)

Ive already uploaded some laravel 5 projects to test but my problem was i moved out the public folder out of the main folder :(

07 Jun
4 years ago

MarkMatute left a reply on One Form 2 Models

public function store(CreateEmployeeRequest $request) { //GENERATE CONFIRMATION CODE $confirmation_code =str_replace('/','*', Hash::make($request->password));

    //TRY TO SEND EMAIL CONFIRMATION
    try{
        //CALL METHOD TO SEND CONFIRMATION EMAIL
        $this->sendConfirmationEmail(Input::get('email'),$confirmation_code);
        //SAVE REQUESTS VARIABLES TO @PARAMS
        $employee_params = $request->all();

        //GENERATE IMAGE FILE NAME
        $image_file = $this->generateImageFileName();

        //CHECK IF USER CHOOSES A PROFILE PICTURE
        if($request->hasFile('image')){
            //GET THE IMAGE FROM THE REQUEST
            $img = Image::make($request->file('image'));
            $img->resize(150,150);
            //MOVE THE IMAGE TO PUBLIC IMAGES DIRECTORIES
            $img->save("images/employees/profile_image/$image_file.jpg");
            //SAVE IMAGE TO EMPLOYEE PARAMS
            $employee_params['image'] = "images/employees/profile_image/$image_file.jpg";

        //IF PROFILE IMAGE WAS NOT SET
        }else{
            //SAVE DEFAULT IMAGE AS PROFILE IMAGE
            $employee_params['image'] = "";
        }

        //SAVE THE USER
        $employee = Employee::create($employee_params);

        //GET THE LATEST SAVED EMPLOYEE
        $employee = new Employee();
        $employee = Employee::where('email','=',$request->email)->first();

        //SAVE THE USER ACCOUNT
        $this->saveEmployeeUserAccount($request,$employee,$confirmation_code);

        //SET A SUCCESS MESSAGE
        flash()->success('Employee Saved! Please be reminded that an email confirmation was sent!');

        //REDIRECT BACK TO EMPLOYEES PAGE
        return redirect('employees');

    //SHOW ERROR IF EMAIL WAS UNABLE TO SEND
    }catch (\Swift_TransportException $e){
        flash()->error('Employee Failed! Email not sent!');
        return redirect('employees');
    }

}

This is my code, its working but is there still a way to clean up these code? :)

MarkMatute left a reply on Saving Image Upload And File To A Folder In My Laravel

$file->move($destinationPath, $filename); works like move_uploadedfile i guess :))) Ive been working on that for 2 dayss :D You may also check out the package 'intervention/image '

MarkMatute left a reply on Registration And Login System

Laravel 5 comes with Reg and Login Out of the box. If you want to know how it works you need to look under the hood :)

MarkMatute started a new conversation One Form 2 Models

Hi.Im been in Laravel 5 for a while now. My problem was I need to have 1 Form then after submitting i need to save the form requests into two models, i had it working but im not satisfied with my solution... Can anybody have same problem here? :)