muazzamazaz

muazzamazaz

Member Since 1 Year Ago

Experience Points 2,600
Experience Level 1

2,400 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 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.

26 May
3 weeks 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
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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
2 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
2 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();
    }
}

13 Nov
1 year ago

muazzamazaz started a new conversation Select Option Property Not Working

<select name="notificationtype" required class="form-control">
    <option value="sms" @if($template->type=='sms') "selected=true" else "selected=false" @endif > SMS </option>
    <option value="email" @if($template->type=='email') "selected=true" else "selected=false" @endif > Email </option> 
</select>
11 Nov
1 year ago

muazzamazaz left a reply on Call To A Member Function GetUpdatedTemplate() On Null

@Snapey after change it shows

No query results for model [App\Notification_Template].

muazzamazaz left a reply on Call To A Member Function GetUpdatedTemplate() On Null

@andonovn

CREATE TABLE `notification_templates` (
  `id` int(11) NOT NULL,
  `type` varchar(20) NOT NULL,
  `title` varchar(200) NOT NULL,
  `email_subject` varchar(500) NOT NULL,
  `message` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
09 Nov
1 year ago

muazzamazaz started a new conversation Call To A Member Function Save() On Null

    public function Save_Template(Request $request)
    {
        $templateValidation = new Notification_Template();
        $validator       = $templateValidation->getValidatedData($request);
        $template           = Notification_Template::find($request->id);

        if ($validator->fails()) {
            $error_messages = implode(',', $validator->messages()->all());
            return back()->with('flash_errors', $error_messages);
        } else {
            $template->getUpdatedTemplate($template, $request);
          
            $template->save();

            return back()->with('flash_success', Helper::tr('admin_not_profile'));
        }
    }

at above $template->save(); error throws:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Validator;

/**
 * Responsible for the Admin user
 */
class Notification_Template extends Model
{
    /**
     * Pass the data through the Laravel validator
     * 
     * @param Request $request
     * @return mixed
     */
     public function setUp() {
    parent::setUp();
    // Your code here
}
     protected $table = 'notification_templates';
     protected $guarded = ['Id'];
    protected function passDataThroughValidator(Request $request)
    {
        
           return Validator::make($request->all(), array(
                    'type' => 'max:20',
                    'email_subject' => 'max:300',                    
                    'nessage' => 'max:1000',
                    'title' => 'max:100',                   
                        )
        );
    }
    
    /**
     * Return the updated data after validation
     * 
     * @param Request $request
     * @return mixed
     */

    public function getValidatedData(Request $request)
    {
        return $this->passDataThroughValidator($request);
    }
    
    /**
     * Update the admin profile information
     * 
     * @param \App\Admin $admin
     * @param Request $request
     * @return \App\Admin
     */
    private function updateTemplate(Notification_Template $template, Request $request)
    {
        $template->type = $request->has('type') ? $request->type : $Template->type;
        $template->title = $request->has('title') ? $request->title : $Template->title;
        $Template->email_subject = $request->has('email_subject') ? $request->email_subject : $template->email_subject;
        $Template->message = $request->has('message') ? $request->message : $template->message;
        
        return $template;
    }
  
  private function savetemplateProfile(Notification_Template $template, Request $request)
    {
         $template->type = $request->has('type') ? $request->type : $Template->type;
        $template->title = $request->has('title') ? $request->title : $Template->title;
        $Template->email_subject = $request->has('email_subject') ? $request->email_subject : $template->email_subject;
        $Template->message = $request->has('message') ? $request->message : $template->message;
        
        return $template;
    }
    
    /**
     * Return the updated template profile information
     * 
     * @param \App\template $template
     * @param Request $request
     * @return mixed
     */

     public function getUpdatedtemplate(Notification_Template $template, Request $request)
    {
        return $this->updatetemplate($template, $request);
    }
    
     public function getSavetemplate(Notification_Template $template, Request $request)
    {
        return $this->savetemplate($template, $request);
    }
}

26 Oct
1 year ago

muazzamazaz left a reply on Trying To Get Property Of Non-object Error On Db View

@RamjithAp returning it as

return view('user', compact('top_revenue_users'))
                        ->withPage('user');```

muazzamazaz started a new conversation Trying To Get Property Of Non-object Error On Db View

Getting db view results but error of non-object while view contains rows

$top_revenue_users = DB::table('user_requests')->orderBy('total', 'desc')->take(3);

ody>   
    @foreach ($top_revenue_users as $rc2)
    <tr>
    <td>{{$rc2->first_name}}</td>
    <td>{{$rc2->last_name}}</td>
    <td>{{$rc2->email}}</td>
    
    @endforeach
``

> Trying to get property of non-object 
24 Oct
1 year ago

muazzamazaz started a new conversation SyntaxError: Missing : After Property Id

I have write the following code

 var geocoder =  new google.maps.Geocoder();
 
     var map;
     var markers = [
         @foreach($locationList as $location)
         {
             location_id: "{{ $location->id }}",
             geocoder.geocode( { 'address': "{{ $location->city }}"}, function(results, status) {
           if (status == google.maps.GeocoderStatus.OK) { 
           lat: results[0].geometry.location.lat(),
            lng: results[0].geometry.location.lng(),
           }
         }
         });
             
             
         },
         @endforeach
     ];

But it give me error

SyntaxError: missing : after property id

21 Oct
1 year ago

muazzamazaz started a new conversation Softdeletes Not Working


use Illuminate\Database\Eloquent\SoftDeletes;
class UserController extends Controller
{
use SoftDeletes;


   public function delete_user(Request $request)
    {

        if ($user = User::find($request->id)) {

            $user = User::destroy($request->id);
        }

...

deletes row from table instead of updating delete_at column that exists there.
19 Oct
1 year ago

muazzamazaz started a new conversation Method [validate] Does Not Exist.

namespace App\Http\Controllers;
use App\ContactUS;
use Illuminate\Http\Request;
use App\Http\Requests;
use validator;
use Illuminate\Routing\Controller as BaseController;
class ContactUSController extends BaseController
{
public function contactUS(){
return view('CityOfWorks.ContactUS');
}
public function contactUSPost(Request $request){

$this->validate($request, ['name' => 'required','email' => 'required|email','message' => 'required']);

ContactUS::create($request->all());

return back()->with('success', 'Thanks for contacting us!');
}
}

16 Oct
1 year ago

muazzamazaz started a new conversation Class 'app\Location' Not Found

calling class here in controller:

use app/Location;

....


$validator = Location::getValidatedData($request);

in app folder I have class file Location with class and above function as:

namespace App\Admin;

use Illuminate\Database\Eloquent\Model;
use Symfony\Component\HttpFoundation\Request;
use Validator;

class Location extends Model
{
    public static function getValidatedData(Request $request)
    {
        $data = new Location();
        return $data->passDataThroughValidator($request);
    }
}

02 Oct
1 year ago

muazzamazaz left a reply on Selected Option Not Working

@Snapey I have confirmed that value is there. May be some trailing spaces caused it