muazzamazaz

muazzamazaz

Member Since 1 Year Ago

Experience Points 2,880
Experience Level 1

2,120 experience to go until the next level!

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

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-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.

02 Jul
3 weeks ago

muazzamazaz started a new conversation GOOG_APP_ID=1054369209138-mv3oiau8rof2ml2e33oponfim8ljlfn2.apps.googleusercontent.com GOOG_APP_SECRET=YpKTdvAnSXBFVXAoARn2wmj7 GOOG_CALLBACK_URL=http://lancerdesk.com/login/callback/

.env

GOOG_APP_ID=xxxxxx
GOOG_APP_SECRET=xxxxx
GOOG_CALLBACK_URL=http://example/login/callback/
Controller:

/*** SOCIAL LOGIN ****/
public function redirectToProvider($provider)
{ 
       return Socialite::driver($provider)->scopes(['email'])->redirect(); 
}


public function clean($string) 
    {
    
     $string = preg_replace("/[^\p{L}\/_|+ -]/ui","",$string);

    
    $string = preg_replace("/[\/_|+ -]+/", '-', $string);

    
    $string =  trim($string,'-');

    return mb_strtolower($string);
    }  
   
   
 public function handleProviderCallback($provider)
    { 
        $user = Socialite::driver($provider)->user();
        $authUser = $this->findOrCreateUser($user, $provider);
        Auth::login($authUser, true);      
       return redirect('dashboard');

    }
    
 public function findOrCreateUser($user, $provider)
    {
        $authUser = User::where('provider_id', $user->id)->first();
        if ($authUser) {
            return $authUser;
        }
        return User::create([
            'name'     => $this->clean($user->name),
            'user_slug' => $this->clean($user->name),
            'email'    => $user->email,
            'admin' => 0,
            'confirmation' => 1,
            'provider' => $provider,
            'provider_id' => $user->id
        ]);
    }   

/****** SOCIAL LOGIN ****/
25 Jun
4 weeks ago
24 Jun
1 month ago

muazzamazaz started a new conversation Route Error Forbidden

I have a route like this

   Route::resource('VisitorPlan', 'VisitorPlanController', [
        'names' => [
            'index'   => 'VisitorPlan',
            'destroy' => 'VisitorPlan.destroy',
        ],
    ]);

Controller

  public function create()
    {
     
        return view('VisitorPlan.add-VisitorPlan')->with($data);
        
    }

<form action='VisitorPlan/create' >
                  <input class="btn btn-block" type="submit" value="Create Plane" style="margin-bottom: 100px;margin-top: 50PX;">
</form>

Gives error

Forbidden

It seems controller function Create is being called from route.

23 Jun
1 month ago

muazzamazaz left a reply on Unknown Database Laravel 5.8 New Registration Of User

@SNAPEY - Its a fresh application is being created and now user need to be registered after running command php artisan make auth

muazzamazaz left a reply on Unknown Database Laravel 5.8 New Registration Of User

@SNAPEY - yes tables created successfully.

In my .env file default database was Laravel

Using tinker:

config('database')

"mysql" => [ "driver" => "mysql", "url" => null, "host" => "127.0.0.1", "port" => "3306", "database" => "hotelbooking", "username" => "root", "password" => "", "unix_socket" => "", "charset" => "utf8mb4", "collation" => "utf8mb4_unicode_ci", "prefix" => "", "prefix_indexes" => true, "strict" => true, "engine" => null, "options" => [], ],

muazzamazaz left a reply on Unknown Database Laravel 5.8 New Registration Of User

@SNAPEY - yes But currently running only one, second one also has database named Tourism not Laravel. It seems this application getting default database name after I have added php artisan make auth

muazzamazaz left a reply on Unknown Database Laravel 5.8 New Registration Of User

@SNAPEY - Its showing login/ registration pages. This error comes when I try to register a new user.

muazzamazaz left a reply on Unknown Database Laravel 5.8 New Registration Of User

@NAKOV - Both issues does not exists in this case

muazzamazaz left a reply on Unknown Database Laravel 5.8 New Registration Of User

@NAKOV - .env file contains

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=hotelbooking
DB_USERNAME=root
DB_PASSWORD=

config/database.php

'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],```

muazzamazaz left a reply on Unknown Database Laravel 5.8 New Registration Of User

@NAKOV - I have created a database named HotelBooking and set it in .env file.

muazzamazaz started a new conversation Unknown Database Laravel New Registration Of User

I am getting following error after creating database name HotelBooking in mysql and set this in .env file. I have also run migration successfully but when I try to register user it gives error:

SQLSTATE[HY000] [1049] Unknown database 'laravel'

20 Jun
1 month ago

muazzamazaz started a new conversation Laravel Multiple Join Result Issue

I have following multiple join query in Laravel

    $UserRequests = UserRequests::join('destinations', 'destinations.id', '=', 'destination_id')->leftJoin('request_process', function($join){        
            $join->whereRaw('request_id in (SELECT request_id FROM request_process GROUP by request_id having max(ticket_status)!=2)');
        }
    )
        ->select('process_id','destination_id', 'user_requests.id','name','location','plan_id', 'visit_date','quantity','ticket_status')
        ->get();

It produces results with ticket_status=null if there is:

`ticket_status!=2`

What I want:

  1. It give results if no record in subsequent tables except UserRequests
  2. It should not give result if ticket_status==2
26 May
1 month ago

muazzamazaz started a new conversation Filter Record Via Leftjoin Where Clause If Record Exists

I have tabel request_process as follows:

    requestID Status
    1            0
    1            1
    1            2
    2            0
    2            1

I want to get one row per request with maximum status but only those rows whose status for request is not 2

I want to apply this on where clause of query

    $UserRequests = UserRequests::leftJoin('request_process', function($join){
    $join->on('user_requests.id', '=', 'request_id')->where('status', '!=',2);})
    ->select('*')   
    ->get();

Note: In case no entry in request_process then where clause should not checked.

14 May
2 months ago

muazzamazaz started a new conversation Trying To Get Property 'id' Of Non-object

In the following code, I'm getting error;

public function __construct()
    {
        $this->currentuser = Auth::user()->id;
    }
11 May
2 months ago

muazzamazaz left a reply on Line Break Inside Foeach

@NASMED - <br> tag not working

muazzamazaz started a new conversation Line Break Inside Foeach

 @foreach ($PaymentMethod_detail as $ph)
                                        {!! Form::text('plable[]', nl2br(e($ph->p_method_label)), array('id' => 'plable_lbl', 'class' => 'form-control','multiple' => "multiple" )) !!} 
                                      
@endforeach                           

I want line break after each text box

08 May
2 months ago

muazzamazaz started a new conversation How To Use HasCompositeKey In Model

I have added following package

https://github.com/mpociot/laravel-composite-key

into laravel and getting following error

App\Traits\HasCompositeKey::setKeysForSaveQueryMissing part of the primary key: destination_id

Model:

namespace App\Models;
use App\Traits\HasCompositeKey;

use Illuminate\Database\Eloquent\Model;

class Commission extends Model
{
    use HasCompositeKey;
    protected $table = 'commission';
    protected $primaryKey = ['destination_id','effective_date'];
public $incrementing = false;


    protected $fillable = [
        'destination_id',
        'effective_date',
        'ticketPrice',
        'commPercentage',
    ];
              public function Destination()
    {
        return $this->belongsTo('App\Models\Destination');
    }

}

Controller:

 $commission = Commission::where('destination_id',$id)->where('effective_date',$request->effective_date)->first();

        $input = Input::only('destination_id','effective_date', 'ticketPrice','commPercentage');       

        $commission->fill($input)->save();
07 May
2 months ago

muazzamazaz left a reply on How To Reference Composite Key In Models?

@DMTTTVN - How to call this method in updated method of controller

muazzamazaz left a reply on Updated Record Via Model With Custom Identity Column

$table->unique(['destination_id', 'effective_date'],'unique_commission');

muazzamazaz started a new conversation Updated Record Via Model Without Custom Identity Column

Column not found: 1054 Unknown column 'id' in 'where clause

I have table column name destination_id

  $commission = Commission::where('destination_id',$id)->first();

   $input = Input::only('destination_id','effective_date', 'ticketPrice','commPercentage');       
       
  $commission->fill($input)->save();

muazzamazaz left a reply on The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST.

There was a mistake in form model array id field $commission->id to $commission->destination_id

muazzamazaz left a reply on Laravel 5.8 Default Apache Virtual Host Configuration

run this php artisan config:cache

muazzamazaz left a reply on The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST.

@foram

 {!! Form::model($commission, array('action' => array('[email protected]', $commission->id), 'method' => 'POST')) !!}

                        {!! csrf_field() !!}
<input type="hidden" name="_method" value="PUT">

muazzamazaz left a reply on The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST.

{!! Form::model($destination, array('action' => array('[email protected]', $destination->id),'enctype'=>'multipart/form-data', 'method' => 'PUT')) !!}

This similar code is working fine with route:

Route::resource('destinations', 'DestinationController', [
        'names' => [
            'index'   => 'destinations',
            'destroy' => 'destinations.destroy',
        ],
    ]);

The difference is that $commission being used in model has a join relation with destination model.

$commission = Commission::join('destinations', 'id', '=', 'destination_id')   
    ->select('destination_id','location','name','effective_date', 'ticketPrice','commPercentage')->where('id','=',$id)->first();

muazzamazaz started a new conversation The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST.

Using following code:

Blade:

{!! Form::model($commission, array('action' => array('[email protected]', $commission->id), 'method' => 'PUT')) !!}

web.php

 Route::resource('commissions', 'CommissionController', [
        'names' => [
            'index'   => 'commissions',
            'destroy' => 'commissions.destroy',
        ],
    ]);

Controller

public function update(Request $request, $id)
    {
        
        $commission = Commission::find('destination_id',$id);

        $input = Input::only('destination_id','effective_date', 'ticketPrice','commPercentage');       
     
        $commission->fill($input)->save();

        return redirect('commissions/'.$destination->id)->with('success', trans('commission.updateSuccess'));
    }
29 Apr
2 months ago

muazzamazaz started a new conversation Jquery Not Working With File Input For Preview

I am using following code where image preview is required before uploading


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

<div class="form-group has-feedback row {{ $errors->has('photo') ? ' has-error ' : '' }}">
                                {!! Form::label('photo_lbl', trans('destinations.photoLabelTitle'), array('class' => 'col-md-3 control-label')); !!}
                                <div class="col-md-9">
                                    <div class="input-group">
                                        {!! Form::file('photo[]', null, array('id' => 'photo_title', 'class' => 'form-control')) !!}      
                                        <img src="" id="photo_img" width="200px" />                                 
                                    </div>
                                    @if ($errors->has('photo'))
                                        <span class="help-block">
                                            <strong>{{ $errors->first('photo') }}</strong>
                                        </span>
                                    @endif
                                </div>
                            </div>

Jquery:


function readURL(input) {

        if (input.files && input.files[0]) {

            var reader = new FileReader();

            

            reader.onload = function (e) {

                $('#photo_img').attr('src', e.target.result);

            }

            reader.readAsDataURL(input.files[0]);

        }

    }
$(document).ready(function() {
    $("#photo_title").change(function(){alert(3);

        readURL(this);

    });
});
18 Apr
3 months ago

muazzamazaz left a reply on Error While Creating Database Function In Migration File

Adding End in last has resolved the issue

14 Apr
3 months ago

muazzamazaz left a reply on Error While Creating Database Function In Migration File

I can create it in database successfully, only the issue when I try to create it using migration script.

muazzamazaz left a reply on Error While Creating Database Function In Migration File

I have used DB::Unprepared already but it gives same error. This script works fine at phpmyadmin side.

muazzamazaz started a new conversation Error While Creating Database Function In Migration File

I am creating a database function through laravel migration script as follows: ` DB::statement(' CREATE or REPLACE FUNCTION plan_status(planid bigint) RETURNS varchar(15) CHARSET latin1 BEGIN DECLARE vcount int;

DECLARE plan_status varchar(15);

SELECT COUNT(*) INTO vcount FROM ticket_purchase WHERE id=planid;

IF vcount >0 THEN SET plan_status= "In Process";

END IF;

SELECT COUNT(*) INTO vcount FROM ticket_delivery WHERE id=planid; if (vcount>0) then set plan_status="Delivered"; end if;

RETURN plan_status; ');`

But it gives me following error:

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check th e manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 18

09 Jan
1 year ago

muazzamazaz started a new conversation MethodNotAllowedHttpException

  {!! Form::open(['url' => 'ContractUpdate', 'files' => true, 'class' => 'form-horizontal']) !!}

Route::get('ContractUpdate','[email protected]');

what could be wrong with form URL?

20 Dec
1 year ago

muazzamazaz left a reply on Undefined Variable: Newsletter

@Robstar I am not using Snapey code because of this error above. I am following @bobbybouwmann code

muazzamazaz left a reply on Undefined Variable: Newsletter

@bobbybouwmann error comes when I insert form without checkbox marked

muazzamazaz left a reply on Undefined Variable: Newsletter

@snapy

it gives me error when I put your code

Type error: Argument 1 passed to App\Http\Controllers\Auth\RegisterController::create() must be an instance of App\Http\Controllers\Auth\Request, array given, called in E:\xampp\htdocs\easyware\vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers.php on line 33

19 Dec
1 year ago

muazzamazaz left a reply on Undefined Variable: Newsletter

@Robstar

The modified code is

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

it still show error > undefined variable

muazzamazaz left a reply on Undefined Variable: Newsletter

@bobbybouwmann I mean when I replaced code as below it still showing

undefiend variable 'newsletter'

return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
        'newsletter' => $data['newsletter'],
    ]);
18 Dec
1 year ago
17 Dec
1 year ago

muazzamazaz started a new conversation Undefined Variable: Newsletter

                                <div class="form-check abc-checkbox">
<input class="form-check-input" id="checkbox2" type="checkbox" name="newsletter" {{ old('newsletter') ? 'checked' : '' }} value=1>
<label class="form-check-label" for="checkbox2">
 Email me newsletters
</label>

class User extends Authenticatable { use Notifiable;

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

class RegisterController extends Controller { ...... protected function validator(array $data) { return Validator::make($data, [ 'name' => 'required|string|max:255', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:6|confirmed', 'newsletter' => 'required', ]); }

/**
 * Create a new user instance after a valid registration.
 *
 * @param  array  $data
 * @return \App\User
 */
protected function create(array $data)
{   
    
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
        'newsletter' => $newsletter 
    ]);
    
$user = User::create($request->all());
    $mailer->sendEmailConfirmationTo($user);
    flash('Please confirm your email address.');
    return redirect()->back();
}
25 Nov
1 year ago

muazzamazaz left a reply on Undefined Variable Template2 V5.2

@tisuchi I have tried both but not working while same is working on laravel 5.4

22 Nov
1 year ago

muazzamazaz left a reply on Undefined Variable Template2 V5.2

@tisuchi I have tried both but not working while same is working on laravel 5.4

21 Nov
1 year ago

muazzamazaz started a new conversation Undefined Variable Template2 V5.2

$result = User::where("device_token", "!=", "")->where("device_type", "!=", "")->get();
        $template2 = DB::table('notification_templates')->get();
        return view('admin.push_notifications', compact('result','template2'))->withPage('push_notifications')->with('sub_page', 'view-push_notifications');

view

@if(($template2))
                            @foreach($template2 as $taken)
                              
                     {{ $taken->title }}
                             
                            @endforeach
                            @endif
20 Nov
1 year ago

muazzamazaz left a reply on Undefined Variable: Template (View:...

@tisuchi view code is

@foreach($template as $taken)
                              
                            {{ $taken->title }}
                             
                            @endforeach

muazzamazaz left a reply on Undefined Variable: Template (View:...

@tisuchi Can you add code here where everything with with

muazzamazaz left a reply on Undefined Variable: Template (View:...

@tisuchi if I use $template2 then it also show error.

muazzamazaz started a new conversation Undefined Variable: Template (View:...

$result = User::where("device_token", "!=", "")->where("device_type", "!=", "")->get();
        $template = DB::table('notification_templates')->get();
        return view('admin.push_notifications', compact('result','template'))->withPage('push_notifications')->with('sub_page', 'view-push_notifications');


 @foreach($template as $taken)
                              
                            {{ $taken->title }}
                             
                            @endforeach

15 Nov
1 year ago

muazzamazaz started a new conversation No Users Found

I have table users with two records but following code not getting it

use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\User;
use App\UserRating;
use Hash;
use Illuminate\Http\Request;
use Validator;
use App\Requests;

class UserController extends Controller
{


    public function users()
    {
        $user = User::orderBy('created_at', 'desc')->get();

        return view('admin.users')->withPage('users')->with('sub_page', 'view-user')->with('users', $user);
    }

....
<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\SoftDeletes;

class User extends Authenticatable
{
    use SoftDeletes;
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
    
    /**
     * Fetch the list of recent users by creation date
     * 
     * @return User
     */
    private function fetchRecentUsers()
    {
       
        return $this->orderBy('created_at' , 'desc')->get();
    }
    
    /**
     * Returns a list of recent users by creation date
     * 
     * @return mixed
     */
    public static function getRecentUsers()
    {
        $user = new User();
        return $user->fetchRecentUsers();
    }
}