muazzamazaz

muazzamazaz

Member Since 2 Years Ago

Experience Points
3,040
Total
Experience

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

Level 1
3,040 XP
Oct
19
20 hours ago
Activity icon

Started a new Conversation Read Json In Ajax - Undefined

I am getting following json data in ajax from laravel controller

[{"name":"tests","governorate":"Trento, Province of Trento, Italy","location":"ga","t":48}]

When I read it through

success:function(result)
    {
alert(result.name);
    },

it gives

Undefined.

Oct
16
3 days ago
Activity icon

Started a new Conversation Laravel Route Not Found Using Ajax

Under view I have named view as:

 <script>
    var config = {
        routes: {
            add_plan: "{{ URL::to('destinations.fetch_d') }}"
        }
    };
</script>

Inside web:

Route::post('destinations/fetch_d', '[email protected]_d')->name('destinations.fetch_d');

Inside controller:

 function fetch_d(Request $request)
    {

echo 'test';
    }

Inside custom.js file using Ajax:

$.ajax({
  headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          },
          cache: false,
    url:config.routes.add_plan,
    type: "POST",
    data:id:1,
    success:function(result)
    {
    alert(result);
    },
    error: function(req, textStatus, errorThrown) {
        //this is going to happen when you send something different from a 200 OK HTTP
        alert('Error: ' + textStatus + ' ' +errorThrown);
    }

   });

It gives error

Route Not found under developer console with URL: http://localhost:8000/destinations.fetch_d

Jul
02
3 months ago
Activity icon

Started a new Conversation Social Auth Driver [Callback] Issue Laravel 5.6

.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 ****/

Driver [Callback] Not supported

Route:


Route::get('login/{provider}', 'Auth\[email protected]');
Route::get('login/{provider}/callback', 'Auth\[email protected]');

Jun
25
3 months ago
Jun
24
3 months ago
Activity icon

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.

Jun
23
3 months ago
Activity icon

Replied to 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

Activity icon

Replied to 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" => [],
       ],
Activity icon

Replied to 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

Activity icon

Replied to 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.

Activity icon

Replied to Unknown Database Laravel 5.8 New Registration Of User

@NAKOV - Both issues does not exists in this case

Activity icon

Replied to 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'),
            ]) : [],
        ],```
Activity icon

Replied to Unknown Database Laravel 5.8 New Registration Of User

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

Activity icon

Started a new Conversation Unknown Database Laravel 5.8 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'

There is no cache configured yet

Jun
20
3 months ago
Activity icon

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
May
26
4 months ago
Activity icon

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.

May
14
5 months ago
Activity icon

Started a new Conversation Trying To Get Property 'id' Of Non-object

In the following code, I'm getting error;

use Auth;

----
---

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

Replied to Line Break Inside Foeach

@NASMED - <br> tag not working

Activity icon

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

May
08
5 months ago
Activity icon

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();
May
07
5 months ago
Activity icon

Replied to How To Reference Composite Key In Models?

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

Activity icon

Replied to Updated Record Via Model With Composite Unique Columns

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

Activity icon

Started a new Conversation Updated Record Via Model With Composite Unique Columns

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();
Activity icon

Replied to 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

Activity icon

Replied to Laravel 5.8 Default Apache Virtual Host Configuration

run this php artisan config:cache

Activity icon

Replied to The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST.

@foram The table commission has no identity/ primary key

Activity icon

Replied to The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST.

@foram

Same error with this code

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

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

Replied to 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();

Activity icon

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'));
    }
Apr
29
5 months ago
Activity icon

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);

    });
});
Apr
18
6 months ago
Activity icon

Replied to Error While Creating Database Function In Migration File

Adding End in last has resolved the issue

Apr
14
6 months ago
Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

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

Jan
09
1 year ago
Activity icon

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?

Dec
20
1 year ago
Activity icon

Replied to Undefined Variable: Newsletter

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

Activity icon

Replied to Undefined Variable: Newsletter

@bobbybouwmann error comes when I insert form without checkbox marked

So its means newsletter don't have any value

<input class="form-check-input" id="checkbox2" type="checkbox" name="newsletter" {{ old('newsletter') ? 'checked' : '' }} value=1>

Activity icon

Replied to Undefined Variable: Newsletter

@snapey

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

Dec
19
1 year ago
Activity icon

Replied to 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

Activity icon

Replied to 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'],
    ]);
Dec
18
1 year ago
Dec
17
1 year ago
Activity icon

Started a new Conversation Undefined Variable: Newsletter


<div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <div class="checkbox">
                                                                    
                                    <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>
  </div>

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();
    }
Nov
25
1 year ago
Activity icon

Replied to Undefined Variable Template2 V5.2

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

Nov
22
1 year ago
Activity icon

Replied to Undefined Variable Template2 V5.2

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

Nov
21
1 year ago
Activity icon

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
Nov
20
1 year ago
Activity icon

Replied to Undefined Variable: Template (View:...

@tisuchi view code is

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

Replied to Undefined Variable: Template (View:...

@tisuchi Can you add code here where everything with with