hidayat3676

hidayat3676

Member Since 1 Year Ago

Experience Points 3,830
Experience Level 1

1,170 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 1
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.

11 Jan
4 months ago

hidayat3676 started a new conversation How To Get Data From Polymorphic Relationship

following is my code ~~ model where i have made polymorphic relation ship Relation::morphMap([ 'Company' => 'App\Company', 'Talent' => 'App\CompanyContact' ]); class ImportLog extends Model {

public function resource(){

    return $this->morphTo();
}

} mapping of relationship class CompanyContact extends Model { public function importLog(){

    return $this->morphMany(ImportLog::class,'resource');
}

}

class Company extends Model { public function importLog(){

    return $this->morphMany(ImportLog::class,'resource');
}

}

here is query to imporlog $importedLog = ImportLog::where('import_id', '=',$importId) ->where('status','=','success')->get(); when i foreach and want to get data like below foreach($importLog->importLog as log){ echo $log->name; } it's give me error of invalid argument supplied to foreach

when i want to retrive model of the relationship like below

foreach($importLog->importLog as log){ echo $log->resource; } it's give me error of Method firstItem does not exist ~~ how can i fetch this relationship data?

19 Oct
7 months ago

hidayat3676 started a new conversation How To Get Image Path Using Input Type File

I want to get the path once a user select the image before the submit of the file to db here is my code

 <form action="/updateProfilePicture" method="post" enctype="multipart/form-data">
                        @csrf
                        <div class="form-group">
                            <input type="hidden" name="user_id" value={{Auth::user()->id}}>
                            <input type="file" class="form-control-file" name="image" id="avatarFile" aria-describedby="fileHelp">
                            
                            <small id="fileHelp" class="form-text text-muted">Please upload a valid image file.</small>

@if(exif_imagetype('path/to/image.jpg')) 
                            // your image is valid
                            @endif 
                        </div>
                        <button type="submit" class="btn btn-primary" data-dismiss="model">Submit</button>
                    </form>

i want to check in the above if condition if the selected image is valid or not. How to do this.

16 Oct
7 months ago

hidayat3676 started a new conversation How To Make A Site Multilingual?

One of my client want to create their site in multilingual as such that when user click on Arabic the site with the same functionality is shown to user in the Arabic language, In simple just like facebook main page when we click on Arabic we are shown the Arabic version of the same page. My question is how to do it without using machine translator, Are the site like facebook develop multiple version for each language or it's something in the technology that generate the site in localized language? By now I only have idea of making clone of the site & making it's content manually to localized language. will it work this way or not? Please provide me some idea regarding this. the technology is php.

07 Oct
7 months ago

hidayat3676 started a new conversation How To Show Chart Data In The View

I'm returning a chart to a view following is my code

My controller
public function index(){
        $chartJs = app()->chartjs
            ->name('lineChartTest')
            ->type('line')
            ->size(['width' => 400, 'height' => 200])
            ->labels(['January', 'February', 'March', 'April', 'May', 'June', 'July'])
            ->datasets([
                [
                    "label" => "My First dataset",
                    'backgroundColor' => "rgba(38, 185, 154, 0.31)",
                    'borderColor' => "rgba(38, 185, 154, 0.7)",
                    "pointBorderColor" => "rgba(38, 185, 154, 0.7)",
                    "pointBackgroundColor" => "rgba(38, 185, 154, 0.7)",
                    "pointHoverBackgroundColor" => "#fff",
                    "pointHoverBorderColor" => "rgba(220,220,220,1)",
                    'data' => [65, 59, 80, 81, 56, 55, 40],
                ],
                [
                    "label" => "My Second dataset",
                    'backgroundColor' => "rgba(38, 185, 154, 0.31)",
                    'borderColor' => "rgba(38, 185, 154, 0.7)",
                    "pointBorderColor" => "rgba(38, 185, 154, 0.7)",
                    "pointBackgroundColor" => "rgba(38, 185, 154, 0.7)",
                    "pointHoverBackgroundColor" => "#fff",
                    "pointHoverBorderColor" => "rgba(220,220,220,1)",
                    'data' => [12, 33, 44, 44, 55, 23, 40],
                ]
            ])
            ->options([]);
        return view('chart',compact('chartJs'));
}

My Route.
Route::get('chart','[email protected]');

My view code.
<div style="width:75%;">
    {!! $chartJs->render() !!}
</div>

when i type the url of the route i get a blank view their is no data or chart displayed. what should i do more in order to get the chart shows in the view?

hidayat3676 started a new conversation How To Get Data From Table In Date Wise And Display It On A Chart Based On Hour Of That Day

following is my code

Migration
  public function up()
    {
        Schema::create('panels', function (Blueprint $table) {
            $table->increments('id');
            $table->string('serial');
            $table->decimal('longitude', 9, 6);
            $table->decimal('latitude', 8, 6);
            $table->timestamps();
        });
    }
public function up()
    {
        Schema::create('one_hour_electricities', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('panel_id');
            $table->foreign('panel_id')->references('id')->on('panels')->onDelete('cascade');
            $table->integer('kilowatts');
            $table->datetime('hour');
            $table->timestamps();
        });
    }

i want to get the data from the second migration and show it on chart hourly basis of each day using specific panel id. what type of query will i need to execute to achieve this.

04 Oct
7 months ago

hidayat3676 left a reply on How To Check A Database Collection Data For Null

@Snapey Thanks for quick reply, I resolved using the following method.

if($comment->like->count() == null){
//do something
}
else {
//do some task here
}

hidayat3676 started a new conversation How To Check A Database Collection Data For Null

Hi, I've the following code which is an Api for mobile app.

public function fetchMatchComments($matchId)
    {
        $comments = $this->_comment->all()->where("match_id", $matchId);
        $commentArray = array();
        foreach ($comments as $comment){
            $match_comments["commentId"]     = $comment->id;
            $match_comments["userId"]        = $comment->user_id;
            $match_comments["userImg"]       = $comment->user->image;
            $match_comments["userName"]      = $comment->user->first_name ." ". $comment->user->last_name;
            $match_comments["comment"]       = $comment->text;
            dd($comment->like);
            if($comment->like  == " ") {
                dd("if");
                array_push($commentArray, $match_comments);

            }else{
                foreach ($comment->like as $like) {
                    $match_comments["likeUserId"] = $like->user_id;
                    $match_comments["likeCommentId"] = $like->comment_id;
                    array_push($commentArray, $match_comments);
                }

            }

        }
        return response()->json($commentArray);
    }

if a comment don't have any like data in the corresponding like table, then I shall add that array index no like data or something but if the comment has the like data in the corresponding like table I would like to add it to the array index. I get the following collection when the comment don't have any like data in the like table

Collection {#354 ▼
  #items: []
}

how can I perform check on the above collection so that I execute code of my choice if the return collection as like above.

03 Oct
7 months ago

hidayat3676 left a reply on How To Make Changes ForgetPasswordController Email Of Auth

@Snapey Thanks! It's work but what if I want to change other content of the file like the following:

If you did not request a password reset, no further action is required.

Regards,
Laravel

hidayat3676 left a reply on How To Make Changes ForgetPasswordController Email Of Auth

@Snapey By default it send the following link for reseting password

 http://localhost/password/reset/cf003f848b68bdd6b9efcf23340890fc46f58edae1abf3c329b829013e7229db

I would like to change this to the following.

added port of the localhost
 http://localhost:8000/password/reset/cf003f848b68bdd6b9efcf23340890fc46f58edae1abf3c329b829013e7229db

hidayat3676 left a reply on How To Make Changes ForgetPasswordController Email Of Auth

I would like to make changes in the file send by the following method is an email response to the user. of ForgetPasswordController method below.

   protected function sendResetLinkResponse($response)
    {
      
        return back()->with('status', trans($response));
    }

hidayat3676 started a new conversation How To Make Changes ForgetPasswordController Email Of Auth

Hi, I want to make changes in the file that is send is an email to the user, when user click 'send reset password link' button. how to achieve this I didn't find the file in the view that is send is an email to the user.

24 Jul
10 months ago

hidayat3676 left a reply on How To Set Xampp Php Path To PATH On Mac To Override The Default Php

@Tray this is not working in my i seen at already.

hidayat3676 started a new conversation How To Set Xampp Php Path To PATH On Mac To Override The Default Php

Hi, i've install xampp on my Mac which has php version 7.2.x, but when i type php -v on terminal it's show php version 5.6 which i know is already came with mac because when i type command

which php
it's show me 
usr/local/php

so how do i set my xampp php version to my path because i use it for a laravel 5.6 project which need php 7.1 or 7.2 i tried different method from google but know of it works for me.i'm stuck here without moving to my actual work for a few hour, hope someone have the solution.

hidayat3676 started a new conversation /usr/local/bin/composer.phar: No Such File Or Directory Error On Mac

i just install composer and set it's path through the following commond

echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc

when i open the directory below usr/local/bin i can see composer but when i type composer it's give me error this "/usr/local/bin/composer.phar: No such file or directory" when i write php composer.phr it's again give me error "Could not open input file: composer.phr".hope some one have solve this error to help me out of this problem i'm stuck in it for few hours but didn't found any solution.

21 Jul
10 months ago

hidayat3676 left a reply on How To Access Localhost Route On Vmware MacOS

@newbie360 i did it but it doesn't worked.

18 Jul
10 months ago
17 Jul
10 months ago

hidayat3676 started a new conversation How To Access Localhost Route On Vmware MacOS

i'm on window in which i've xampp server install and also i've vmware running on window in which i'm running macOS. now i want to send data from my localhost to IOS app for that i've written the following code.

controller code
  public function api(){
       $matches = $this->match->show();
       return  response()->json(compact('matches'));
    }
 route
 Route::get('/matchApi', '[email protected]');

my question is that how can i access this route on my vmware Mac. any help would be appreciated.

08 Jun
11 months ago

hidayat3676 left a reply on How To Refresh Page Content Using Ajax

@Grado how the following method will update the data

setTimeout(function tick() {
    $( "#stats_container" ).load( "/ #stats_content" , function() {
        setTimeout(tick, 2000);
    });
}, 2000);

hidayat3676 left a reply on How To Refresh Page Content Using Ajax

@casnv18 but how do i achieve this because here i have to append new row to table and the old are also to be there.

hidayat3676 left a reply on How To Refresh Page Content Using Ajax

@casnv18 okay but how about this data

 @foreach($tournaments as $tournament)
                        <tr>
                            <td>{{$tournament->id}}</td>
                            <td>{{$tournament->name}}</td>
                            <td>{{$tournament->sport->name}}</td>
                            <td>{{$tournament->favorite->count()}}</td>
                            <td>{{$tournament->created_at}}</td>
                        </tr>
                    @endforeach
how this will be updated.

hidayat3676 left a reply on How To Refresh Page Content Using Ajax

@casnv18 not got what you are trying to say, but my question is that how do i refresh these content using ajax.

07 Jun
11 months ago

hidayat3676 started a new conversation How To Refresh Page Content Using Ajax

i have an admin panel in which i have count of total users,total comments and count of many more things i want this panel to be updated with ajax mean when new comment is post or something other or new added to the db the admin shall be able to see the current changes without refreshing the page how can i achieve this through ajax. following is my code.

admin panel code
@extends('layouts.admin')

@section('dashboard_title')
    Dashboard
    @endsection
@section('site_stats')

    <div class="row">
        <div class="col-lg-2 col-md-2">
            <div class="card ks-widget-payment-simple-amount-item ks-green">
                <div class="payment-simple-amount-item-icon-block">
                    <span class="la la-leaf ks-icon"></span>
                </div>

                <div class="payment-simple-amount-item-body">
                    <div class="payment-simple-amount-item-amount">
                        <span class="ks-amount">{{$sports->count()}}</span>
                        <span class="ks-amount-icon ks-icon-circled-up-right"></span>
                    </div>
                    <div class="payment-simple-amount-item-description">
                        Total Sports(s) <span class="ks-progress-type"></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-2 col-md-2">
        <div class="card ks-widget-payment-simple-amount-item ks-green">
            <div class="payment-simple-amount-item-icon-block">
                <span class="la la-leaf ks-icon"></span>
            </div>

            <div class="payment-simple-amount-item-body">
                <div class="payment-simple-amount-item-amount">
                    <span class="ks-amount">{{$stadium->count()}}</span>
                    <span class="ks-amount-icon ks-icon-circled-up-right"></span>
                </div>
                <div class="payment-simple-amount-item-description">
                    Total Stadium(s) <span class="ks-progress-type"></span>
                </div>
            </div>
        </div>
    </div>

        <div class="col-lg-2 col-md-2">
            <div class="card ks-widget-payment-simple-amount-item ks-purple">
                <div class="payment-simple-amount-item-icon-block">
                    <span class="ks-icon-user ks-icon"></span>
                </div>

                <div class="payment-simple-amount-item-body">
                    <div class="payment-simple-amount-item-amount">
                        <span class="ks-amount">{{$users->count()}}</span>
                        <span class="ks-amount-icon ks-icon-circled-down-left"></span>
                    </div>
                    <div class="payment-simple-amount-item-description">
                        Total User(s) <span class="ks-progress-type"></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-2 col-md-2">
            <div class="card ks-widget-payment-simple-amount-item ks-green">
                <div class="payment-simple-amount-item-icon-block">
                    <span class="la la-pie-chart ks-icon"></span>
                </div>

                <div class="payment-simple-amount-item-body">
                    <div class="payment-simple-amount-item-amount">

                        <span class="ks-amount"></span>

                        <span class="ks-amount">{{$teams->count()}}</span>
                        <span class="ks-amount-icon ks-icon-circled-up-right"></span>
                    </div>
                    <div class="payment-simple-amount-item-description">
                        Total Teams <span class="ks-progress-type"></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-2 col-md-2">
            {{--class="card ks-widget-payment-simple-amount-item ks-orange"--}}
            <div class="card ks-widget-payment-simple-amount-item ks-orange">
                <div class="payment-simple-amount-item-icon-block">
                    <span class="la la-area-chart ks-icon"></span>
                </div>

                <div class="payment-simple-amount-item-body">
                    <div class="payment-simple-amount-item-amount">
                        <span class="ks-amount">{{$players->count()}}</span>
                        <span class="ks-amount-icon ks-icon-circled-up-right"></span>
                    </div>
                    <div class="payment-simple-amount-item-description">
                        Total Players <span class="ks-progress-type"></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-2 col-md-2">
            <div class="card ks-widget-payment-simple-amount-item ks-pink">
                <div class="payment-simple-amount-item-icon-block">
                    <span class="ks-icon-user ks-icon"></span>
                </div>

                <div class="payment-simple-amount-item-body">
                    <div class="payment-simple-amount-item-amount">
                        <span class="ks-amount">{{$comments->count()}}</span>
                        <span class="ks-amount-icon ks-icon-circled-down-left"></span>
                    </div>
                    <div class="payment-simple-amount-item-description">
                        Total Comments <span class="ks-progress-type"></span>
                    </div>
                </div>
            </div>
        </div>

    </div>
@endsection
@section('Admins_section')
    <div class="row">
        <div class="col-md-6">

            <div class="card ks-card-widget ks-widget-payment-table-invoicing">
                <h5 class="card-header">
                    Sports
                </h5>
            <table id="sport-table" class="table table-striped table-bordered" width="100%">
                <thead>
                <tr>
                    <th>#</th>
                    <th>Name</th>
                    <th>Added Date</th>
                </tr>
                </thead>
                <tbody>
                    @foreach($sports as $sport)
                        <tr>
                            <td>{{$sport->id}}</td>
                            <td>{{$sport->name}}</td>
                            <td>{{$sport->created_at}}</td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>
        <div class="col-md-6">

            <div class="card ks-card-widget ks-widget-payment-table-invoicing">
                <h5 class="card-header">
                    Tournaments
                </h5>
                <table id="tournament-table" class="table table-striped table-bordered" width="100%">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>Name</th>
                        <th>Sport</th>
                        <th>Favorites</th>
                        <th>Added Date</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($tournaments as $tournament)
                        <tr>
                            <td>{{$tournament->id}}</td>
                            <td>{{$tournament->name}}</td>
                            <td>{{$tournament->sport->name}}</td>
                            <td>{{$tournament->favorite->count()}}</td>
                            <td>{{$tournament->created_at}}</td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection

my controller code from where data is passing to admin panel
public function dashboard(){


      
        
        $players    = $this->_player->fetchAll();
        $users      = $this->_user->fetchAll();
        $tournament = $this->_tournament->fetchAll();
        $stadium    = $this->_stadium->fetchAll();
        $team       = $this->_team->fetchAll();
        $comment    = $this->_comment->fetchAll();
        //$favorite_tournament = $this->_tournament_c->mostFavorite();
        $sport = $this->_sport->fetchAll();
        return view('home.backend.dashboard',['players'=>$players, 'users'=>$users, 'tournaments'=> $tournament, 'teams'=>$team, 'comments' => $comment,'sports' => $sport,'stadium' => $stadium]);

    }
01 Jun
11 months ago

hidayat3676 left a reply on Sending Email To Log File In Laravel

@arukomp now i'm getting token but when i copy link from log file it's not working my link is follows. it's show me a blank page with message 'sorry , the page you are looking for could not be found' http://127.0.0.1:8000/verify/[email protected]/X649lD6p9JlsMk06HlnhMmcKj

hidayat3676 started a new conversation Sending Email To Log File In Laravel

hi, i have the following code in which i want to send an email verification link to the user using log driver

my mailer code
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class VerifyUserEmail extends Mailable
{
    use Queueable, SerializesModels;

   
    public $user;
    public function __construct($user)
    {
        $this->user = $user;
    }

  
    public function build()
    {
        return $this->from('[email protected]')->view('auth.verifyEmail');
    }
}
 my view code which i'm sending

<a href='{{url("verify/$user->email/$user->verify_token")}}'>Click here to verify your email</a>
my register controller

<?php

namespace App\Http\Controllers\Auth;


use App\Models\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Auth\Events\Registered;
use App\Mail\VerifyUserEmail;

class RegisterController extends Controller
{
    

    use RegistersUsers;

    protected $redirectTo = '/';
    protected $fillable = ['first_name','last_name' ,'email','verify_token'
    ];

    public function __construct()
    {

    }

    protected function validator(array $data)
    {

        return Validator::make($data, [
            'first_name' => 'required|string|max:255',
            'last_name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|min:6|confirmed',
        ]);
    }

    protected function create(array $data)
    {

       $user= User::create([
            'first_name' => $data['first_name'],
            'last_name' => $data['last_name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'verify_token' => str_random('25'),
        ]);
    Mail::to($user->email)->send(new VerifyUserEmail($user));
    return $user;

    }

    public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));
        Auth::logout();
        return redirect('login')->with('message','A verification link has been send to your email Address, you need to verify your email first.');
       // $this->guard()->login($user);

        //return $this->registered($request, $user)
          //  ?: redirect($this->redirectPath());
    }
    public function verifyUserEmail($email,$token){

        $user = User::where(['email', $email],['verify_token',$token])->first();
        if ($user){
            $user->verify_token    = '';
            $user->verify_status   = 1;
            return redirect('login')->with('message','Congratulation! You have successfully verified your Email Login Now!');
        }

    }
}

my web route for verification
Route::get('verify/{$email}{$token}','[email protected]');

after registration all works fine but when i see in log file i get thing like this

[2018-06-01 07:51:52] local.DEBUG: Message-ID: cfa31954f7072a6215d4db74b1cc6a31@127.0.0.1 Date: Fri, 01 Jun 2018 07:51:52 +0000 Subject: Verify User Email From: hidayat3676@gmail.com To: [email protected] MIME-Version: 1.0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

Click" target="_blank" rel="noreferrer noopener">http://127.0.0.1:8000/verify/[email protected]'>Click here to verify your email

here in the log file i'm only getting email of the user and not its token, hope someone have solution to this. second question is that can i remove the html tag from this link send to log file, i mean in log file i only have the link like this. http://127.0.0.1:8000/verify/[email protected]

hidayat3676 started a new conversation ErrorException (E_WARNING) Stream_socket_enable_crypto(): SSL Operation Failed With Code 1. OpenSSL Error Messages

Hi, i used php mail to send email but i'm getting error below

ErrorException (E_WARNING) stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed i don't know where is the problem.

hidayat3676 left a reply on How To Verify User Email Using Middle Ware With Auth

@Cronix i want scenario like this. 1: when user fill the registration form and click submit 2: user should not login to application 3: user should be send to the middle ware 4: in the middle ware i would check user for verification and redirect it to login page with message that you need to verify your email.

31 May
11 months ago

hidayat3676 left a reply on How To Verify User Email Using Middle Ware With Auth

@lostdreamer_nl by using your code in middleware it show me 'No user'

hidayat3676 left a reply on How To Verify User Email Using Middle Ware With Auth

the url address is 
http://127.0.0.1:8000/register

my login controller
use AuthenticatesUsers;


    protected $redirectTo = '/';

   
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }
}

my web.php

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

    Auth::routes();

    //user home page route
    Route::get('/', '[email protected]')->name('home')->middleware('guest');

    Route::group(['middleware' => 'guest'], function(){

    //tournament page
        Route::resource('/tournament','TournamentController');

    //admin route
        Route::get('/admin','[email protected]');

    //news route
        Route::get('/news','[email protected]')->name('news');
        Route::get('/news-detail','[email protected]')->name('news-detail');

    //team route
        Route::get('/team','[email protected]')->name('team');
        Route::get('/team-info/{id}','[email protected]')->name('team-info');

    //standing route
        Route::get('/standings','[email protected]')->name('standings');
        Route::get('/standings/{id}','[email protected]')->name('standings-show');


    // Player Routes
        Route::get('players','[email protected]')->name('players');
        Route::get('player-info/{id}','[email protected]')->name('player-info');
//        Route::get('/count-player','[email protected]')->name('count-player');
    //scoreBoard Route
        Route::get('/score-board','[email protected]')->name('score-board');
        Route::get('/score-info/{id}','[email protected]')->name('score-info');


        //match route
        Route::get('/schedule','[email protected]')->name('schedule');

        Route::get('/live','[email protected]')->name('liveScore');

    });

hidayat3676 left a reply on How To Verify User Email Using Middle Ware With Auth

ok i'll follow the naming convention but my question is that if i uncomment the code in the middleware then i don't get the registration form. it show me a blank page with text Sorry, the page you are looking for could not be found.

hidayat3676 left a reply on How To Verify User Email Using Middle Ware With Auth

please some one help me with this issue

hidayat3676 started a new conversation How To Verify User Email Using Middle Ware With Auth

this is my initial code

my middle ware
<?php

namespace App\Http\Middleware;

use Closure;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
class verifyUserEmail
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
       /* $user = User::findOrFail(Auth::id());
        if($user->first_name != 'hidayat'){
            Auth::logout();
            return redirect('login')->with('message','you are not verified user.');
        }*/
        return $next($request);
    }
}

my register controller
<?php

namespace App\Http\Controllers\Auth;

use App\Models\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Auth\Events\Registered;

class RegisterController extends Controller
{
 
    

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */



    protected $redirectTo = '/login';


    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('verify');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {

        return Validator::make($data, [
            'first_name' => 'required|string|max:255',
            'last_name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|min:6|confirmed',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\Models\User
     */
    protected function create(array $data)
    {

       return User::create([
            'first_name' => $data['first_name'],
            'last_name' => $data['last_name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password'])
        ]);


    }

    public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));
       // Auth::logout();
        $this->guard()->login($user);

        return $this->registered($request, $user)
            ?: redirect($this->redirectPath());
    }
}

this is the kernal code
protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verify' => \App\Http\Middleware\verifyUserEmail::class,
    ];
}


when i use the middlware then it doesn't show registration form it redirect user to
Sorry, the page you are looking for could not be found. 
what is the problem with middle ware.

30 May
11 months ago

hidayat3676 left a reply on E_NOTICE : Type 8 -- Array To String Conversion -- At Line 7 Array

result of print_r()


Array ( [Mr-Imran] => Array ( [0] => SimpleXMLElement Object ( [projectBudget] => 125000 [EmpNo] => E100 [DeptName] => IT [HourlyRate] => 625 ) [1] => SimpleXMLElement Object ( [projectBudget] => 120000 [EmpNo] => E101 [DeptName] => Database [HourlyRate] => 500 ) [2] => SimpleXMLElement Object ( [projectBudget] => 135000 [EmpNo] => E102 [DeptName] => IT [HourlyRate] => 550 ) [3] => SimpleXMLElement Object ( [projectBudget] => 115000 [EmpNo] => E103 [DeptName] => Testing [HourlyRate] => 400 ) [4] => SimpleXMLElement Object ( [projectBudget] => 150000 [EmpNo] => E110 [DeptName] => Database [HourlyRate] => 375 ) [5] => SimpleXMLElement Object ( [projectBudget] => 140000 [EmpNo] => E112 [DeptName] => Testing [HourlyRate] => 425 ) ) ) 

hidayat3676 started a new conversation E_NOTICE : Type 8 -- Array To String Conversion -- At Line 7 Array

i write code below

<?php
$xml = "<?xml version='1.0' encoding='UTF-8'?> <Projects_Detail> <Mr-Imran> <projectBudget> 125000</projectBudget> <EmpNo> E100</EmpNo> <DeptName> IT</DeptName> <HourlyRate> 625</HourlyRate> </Mr-Imran> <Mr-Imran> <projectBudget> 120000</projectBudget> <EmpNo> E101</EmpNo> <DeptName> Database</DeptName> <HourlyRate> 500</HourlyRate> </Mr-Imran> <Mr-Imran> <projectBudget> 135000</projectBudget> <EmpNo> E102</EmpNo> <DeptName> IT</DeptName> <HourlyRate> 550</HourlyRate> </Mr-Imran> <Mr-Imran> <projectBudget> 115000</projectBudget> <EmpNo> E103</EmpNo> <DeptName> Testing</DeptName> <HourlyRate> 400</HourlyRate> </Mr-Imran> <Mr-Imran> <projectBudget> 150000</projectBudget> <EmpNo> E110</EmpNo> <DeptName> Database</DeptName> <HourlyRate> 375</HourlyRate> </Mr-Imran> <Mr-Imran> <projectBudget> 140000</projectBudget> <EmpNo> E112</EmpNo> <DeptName> Testing</DeptName> <HourlyRate> 425</HourlyRate> </Mr-Imran> </Projects_Detail> "; 
$obj = simplexml_load_string($xml); 
$array = (array) $obj; 

foreach($array as $ar){
    echo $ar ;
}
?>


i want in the loop array value shall be retrieved but it give me error :E_NOTICE : type 8 -- Array to string conversion -- at line 7 Array what m i doing wrong

29 May
11 months ago

hidayat3676 left a reply on How Can I Pass Multiple Variables Or Array To View

this both works but i use like this

$total = array('totalplayer'=>$totalPlayer,'totalstadium'=> $totalstadiums);
        return view('home.dashboard',compact('total'));
which also work fine.

hidayat3676 started a new conversation How Can I Pass Multiple Variables Or Array To View

i want to pass many variables or array to view how can i pass it.

my code
public function dashboard(){
        $totalPlayer = $this->player->countPlayer();
        $totalstadium = $this->stadium->show();
        $totalusers      = $this->user->countuser();
        return view('home.dashboard');
    }
how can i pass multiple variable or arrays with this view.

hidayat3676 started a new conversation Illuminate\Database\QueryException : SQLSTATE[HY000]: General Error: 1005 Can't Create Table `sports_liga`.`#sql-1158_5ef` (errno: 150 "Foreign Key Constraint Is Incorrectly Form Ed")

i have the following code

stadium migration 

    public function up()
    {
        Schema::create('stadiums', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('team_id');

            $table->string('team_name');
            $table->foreign('team_id')->references('id')->on('teams');
            $table->string("name");
            $table->text("description")->nullable();
            $table->string("location");
            $table->integer("capacity");
            $table->timestamps();
        });
    }

team migration


 public function up()
    {
        Schema::create('team', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('tournament_id');
            $table->foreign('tournament_id')->references('id')->on('tournaments');
            $table->string("name");
            $table->string("home_stadium")->nullable();
            $table->text("description");
            $table->string("location");
            $table->string("team_badge")->nullable();
            $table->string("country");
            $table->string("gender");
            $table->string("team_jersey");
            $table->string("short_name")->nullable();
            $table->string("fanart1")->nullable();
            $table->string("fanart2")->nullable();
            $table->string("fanart3")->nullable();
            $table->string("manager");
            $table->string("establish_at");
            $table->timestamps();
        });
    }


stadium model

  public function match()
    {
        return $this->belongsToMany(Match::Class);
    }

    public function image()
    {
        return $this->hasMany(Image::Class);
    }
    public function team(){
        return $this->belongsTo(Team::class);
    }


team model


 public function tournament()
    {
        return $this->belongsTo(Tournament::Class);
    }

    public function player()
    {
        return $this->hasMany(Player::Class);
    }

    public function match()
    {
        return $this->hasMany(Match::Class);
    }

    public function standing()
    {
        return $this->hasMany(Standing::Class);
    }

    public function image()
    {
        return $this->hasMany(Image::Class);
    }

    public function scoreBoard()
    {
        return $this->hasMany(ScoreBoard::Class);
    }

    public function inning()
    {
        return $this->hasMany(Inning::Class);
    }

    public function goal()
    {
        return $this->hasMany(Goal::Class);
    }

    public function card()
    {
        return $this->hasMany(Card::Class);
    }

    public function notification()
    {
        return $this->belongsToMany(Notification::Class);
    }

    public function favorite()
    {
        return $this->belongsToMany(Favorite::Class);
    }
    public function stadium(){
        return $this->hasOne(Stadium::class);
    }
}

when i migrate it's give me error this: Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table sports_liga.#sql-1158_5ef (errno: 150 "Foreign key constraint is incorrectly form ed") (SQL: alter table stadiums add constraint stadiums_team_id_foreign foreign key (team_id) references teams (id))

26 May
1 year ago

hidayat3676 left a reply on How To Get Total Views Of Site

i mean when user visit my site the view is count , but after that if the same user left the site and visit the site again then another view is count.

hidayat3676 started a new conversation How To Get View Of Sites

how can i count total views of site in php or laravel, i mean when user visit my site the site views shall counts. how can i do this? any help will be extremely appreciated.

24 May
1 year ago

hidayat3676 left a reply on PDOException::("SQLSTATE[42S02]: Base Table Or View Not Found

i don't know why is this error i showed both migration and model file above my table is stadiums but in the error i'm getting that table stadia is not found.

hidayat3676 started a new conversation PDOException::("SQLSTATE[42S02]: Base Table Or View Not Found

i have the following code

this is my model function


    public function store($data)
    {
        foreach ($data['teams'] as $stad){
            $stadium              = new Stadium;
           // $stad->team_id     = $stadium['idTeam'];
            $stadium->name        = $stad['strStadium'];
            $stadium->description = $stad['strStadiumDescription'];
            $stadium->location    = $stad['strStadiumLocation'];
            $stadium->capacity    = $stad['intStadiumCapacity'];
            $stadium->save();

        }
     echo "<h1 align='center'>Records inserted successfully.</h1>";
    }

My migration


public function up()
    {
        Schema::create('stadiums', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('team_id');
            $table->foreign('team_id')->references('id')->on('teams');
            $table->string("name");
            $table->text("description");
            $table->string("location");
            $table->integer("capacity");
            $table->timestamps();
        });
    }

when i call function of the controller it's throw me the following error

2 PDO::prepare("insert into stadia (name, description, location, capacity, updated_at, created_at) values (?, ?, ?, ?, ?, ?)") C:\xampp\htdocs\SportsLiga\vendor\laravel\framework\src\Illuminate\Database\Connection.php:452

what could be the issue ?

hidayat3676 left a reply on How To Check Whether Model Method SaveorFail() Inserted Record In Db

by putting the above if statement it give me syntax error "Upexpected constant reference"

hidayat3676 left a reply on How To Check Whether Model Method SaveorFail() Inserted Record In Db

@Mahmoudy i mean where to put this statement in the function

hidayat3676 started a new conversation How To Check Whether Model Method SaveorFail() Inserted Record In Db

i'm doing the following work in my model


public function store($param){
    $checkInsert  = false;
    foreach ($param['events'] as $event){
    $match               = new Match;
    $match->id           = $event['idEvent'];
    $match->first_team   = $event['strHomeTeam'];
    $match->second_team  = $event['strAwayTeam'];
    // $match->tournament_id  = $event['idLeague'];
    $match->date         = $event['dateEvent'];
    $match->start_date   = $event['strDate'];
    $match->spectators   = $event['intSpectators'];
    $match->season       = $event['strSeason'];
    $match->round        = $event['intRound'];
    $match->start_time   = date('h:i:s', strtotime($event['strTime']));
    $match->saveOrFail();

    }

}

how can i check whether the method saveOrFail() inserted a record.