fahad

fahad

Member Since 3 Years Ago

Munshigonj, Dhaka

Experience Points
32,890
Total
Experience

2,110 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
243
Lessons
Completed
Best Reply Awards
10
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 7
32,890 XP
Mar
19
6 months ago
Activity icon

Replied to Old Value Not Work Properly After Validation Run In Radio Button

just use an strict check instead of only relying upon old('ql')

 <input type="radio" id="2" name="q1" value="2" {{ (old('q1') && old('q1') == 2) ?  'checked' : ' ' }}>

 <input type="radio" id="3" name="q1" value="3" {{ old('q1') && old('q1') == 3) ?  'checked' : ' ' }}>

 <input type="radio" id="4" name="q1" value="4" {{ old('q1') && old('q1') == 4) ?  'checked' : ' ' }}>


Mar
18
6 months ago
Activity icon

Started a new conversation Mock Error In PhpUnit Test

I am always getting error while writing a simple test, don't know what's wrong there, any sort of help is highly appreciated.

Method pluck(<Any Arguments>) from Mockery_6_App_Models_EmailList should be called
 exactly 1 times but called 0 times

My Method is as below:


public function getDoNotEmailers(EmailList $list)
{
   return $list->pluck('email');
} 

and My test

class getDoNotEmailersTest extends TestCase{

  public function testGetDoNotEmail()
  {
     $mock = Mockery::mock('App\Models\EmailList');

     $mock->shouldReceive('pluck')->once()->andReturn('abracadebra'):

     $list = new EmailList(['email' => '[email protected]'])
     $actual = $this->sut->getDoNotEmailers($list):
 
  }
}


Feb
15
1 year ago
Activity icon

Started a new conversation Override A Function Form Package Model

Hi,

I am using Venturecraft\Revisionable packages to preserve history log in my app. And my user model uses soft delete trait. Now i want to see the revision histroy with user in action even if the user is softly deleted.

I already know that if i use withTrashed() method at

vendor/venturecraft/revisionable/src/venturecraft/revisionable/Revision.php

userResponsible() function, it will work.

But the issue is changing directly in the vendor package model is not a good solution at all and i believe there should be some unknown way to override this from my app.

Can any one please help to overcome this barrier?

Thanks in Advance

Oct
03
2 years ago
Activity icon

Started a new conversation How To Split A Large Form Into Several Components

let say I have a large form with 5 different block e.g:

 <form>

    <!-- user info block -->
        <input v-model="user.name">
        <input v-model="user.email">
    <!-- /user info block -->

    <!-- user address block -->
        <input v-model="user.street">
        <input v-model="user.zip">
    <!-- /user address block -->

    <!-- user business info block -->
        <input v-model="user.occupation">
        <input v-model="user.monthly_income">
    <!-- /user business info block -->

 <!--  and some others -->

   <button type="submit> Create Account </submit>
</form>


is it possible to achieve something as follows( i wan to send all the data when user click submit):

<form>

    <!-- user info block -->
       <user-info></user-info>
    <!-- /user info block -->

    <!-- user address block -->
       <user-address></user-address>
    <!-- /user address block -->

    <!-- user business info block -->
        <user-business></user-business>
    <!-- /user business info block -->

 <!--  and some others -->

   <button type="submit> Create Account </submit>
</form>

Is it possible to split them into components and send the request with all data using this submit button / or how can i make them re-usable vuejs block, so that i can simple reuse them for Edit form, ProfileForm etc.

Any help will be highly appreciated.

Sep
27
2 years ago
Activity icon

Replied to How To Get Current Dropzone Selector

update: this line should remove( just copied from the sample question as it was) form the param obj

photo_type: 1, //$(this).hasClass('before') ? 1 : 2, // i need to find which source is using dropzone

Activity icon

Replied to How To Get Current Dropzone Selector

nope it is not a param type, i am just adding an extra param to send, here is my solution and it works finally:


$("div#after, div#before").dropzone({ 

    
              init: function(){                    
                    this.on("sending", function(file, xhr, formData) { 
                        formData.append('photo_type',                $(this.element).hasClass('before') ? 1: 2);    
                    });
                },  

                url: "/admin/photos/",
                params: {
                    _token: '{{ csrf_token() }}',
                    paramName: 'photo',
                    photo_type: 1, //$(this).hasClass('before') ? 1 : 2, // i need to find which source is using dropzone
                    parallelUploads: 1,
                }
});

the key thing was to use and event 'sending' in my case and this.element will supply the current trigger source.

Thanks all for helping.

Activity icon

Started a new conversation How To Get Current Dropzone Selector

I have added two elements to use dropzone ( div#before, div#before), how can i get which one is currently triggering dropzone, since i need to passed a param based on the selector condition, here is my code

$("div#after, div#before").dropzone({ 
                init: function(){
                    console.log($(this));
                },
                url: "/admin/photos/",
                params: {
                    _token: '{{ csrf_token() }}',
                    paramName: 'photo',
                    photo_type: 1, //$(this).hasClass('before') ? 1 : 2, // i need to find which source is using dropzone
                    parallelUploads: 1,
                }
});

Any help is highly appreciated. thanks

Sep
18
2 years ago
Activity icon

Replied to How To Make Each Authenticated User Only See Their Own Data

if you only want to show the user's specific note for the authenticated user, you should modify your web.php as follows:


Route::get('/notes', function () {
   $user = auth()->user();
  return $user->notes()->get();
});

Route::get('/notes/{id}', function ($id) {
   
  $note =  App\Note::findOrFail($id);
  if($note->user_id == auth()->id()){
      return $note;
   }
  return "Only the owner can see his note.";
});

Jul
24
2 years ago
Activity icon

Started a new conversation Laravel Passport Unauthenticated Error For Own App Ajax Call

I am using Laravel-5.3 and attempting to use Laravel Passport. In my project I am using multi auth e.g my user will login as

// normally auth()->user()

auth()->guard('user')->user()

I am getting error at the passport fronend, All default ajax request by passport is returning

http://mydomain.dev/oauth/clients 401 (Unauthorized)
http://mydomain.dev/oauth/tokens 401 (Unauthorized)
http://mydomain.dev/oauth/scopes 401 (Unauthorized)
http://mydomain.dev/oauth/personal-access-tokens 401 (Unauthorized)

and generates uncaught in promise.

Any help is highly appreciated.

Activity icon

Started a new conversation Laravel Passport Implementation For Auth()->guard('user')->user()

Hi,

I am attempting to implement Laravel Passport in my project( Using Laravel 5.3.31 & Passport ~1.0). In in I am using different user table and guarded them.

so instead of $request->user(), in my project i am using $request->guard('user')->user().

After following the Laravel doc for passport implementation, I have done all of the steps, but getting unauthorized error.

At console:

 //Browser console error

GET http://asta.dev/oauth/clients 401 (Unauthorized)
GET http://asta.dev/oauth/tokens 401 (Unauthorized)
GET http://asta.dev/oauth/personal-access-tokens 401 (Unauthorized)
GET http://asta.dev/oauth/scopes 401 (Unauthorized)

// and of-course for all of them
Uncaught (in promise)

Can anyone please help to overcome this barrier. Thanks in advance.

Jul
15
2 years ago
Activity icon

Replied to Nullable Date That Is Registered As Eloquent Carbon Date

Ooops, sorry solved. my fault::

instead of writing this logic

 $item->schedule_date = $request->schedule_date ? Carbon::createFromFormat('m-d-Y', $request->schedule_date)->format('Y-m-d') : null;

mistakenly I have written


 $item->schedule_date = $item->schedule_date ? Carbon::createFromFormat('m-d-Y', $request->schedule_date)->format('Y-m-d') : null;

Activity icon

Started a new conversation Nullable Date That Is Registered As Eloquent Carbon Date

I have added

 protected $dates = ['schedule_date'];

at my model, but sometime it may be null, in case of null now i am getting error while attempting to update the row.

(1/1) InvalidArgumentException
Data missing

Any help is highly appreciated. Thanks

Jul
13
2 years ago
Activity icon

Started a new conversation How To View Storage/custome Directory Image In View

I have uploaded some images at storage/app/avatar directory instead of default storage/app/public directory and run the command

php artisan storage:link

but it only symlink the public directory and i can't access avatar directory images. Can anyone please help.

Thanks

Jul
11
2 years ago
Activity icon

Started a new conversation How To Use Npm Package In Laravel 5.4

I am trying to use https://www.npmjs.com/package/js-datepicker package in my Laravel 5.4 project. so far what i have done:

at bootstrap.js
--------------------

require('js-datepicker');

at app.js
------------

// after vue instance

const picker = datepicker('.schedule_date');


it shows me the following error: in console

Uncaught ReferenceError: datepicker is not defined
    at HTMLDocument.<anonymous> (orders:847)
    at mightThrow (app.js:7700)
    at process (app.js:7768)
(anonymous) @ orders:847
mightThrow @ app.js:7700
process @ app.js:7768

Any help is highly appreciated. Thanks

Activity icon

Started a new conversation How To Use Npm Package In Laravel 5.4( Mix )

Can anyone please guide me to use https://www.npmjs.com/package/js-datepicker with npm install approach.

Thanks in advance

Jun
30
2 years ago
Activity icon

Replied to How To Sort Results By A Related Tables Column

These links are helpful on this issue:

https://stackoverflow.com/questions/23530051/laravel-eloquent-sort-by-relation-table-column

https://laracasts.com/discuss/channels/general-discussion/eloquent-order-by-related-table

Working code block at my file:

jobs.php / jobOffers.php
------------------------------------------------
  // added another scope
    
    public function scopeOrderByPremium($q){

        return $q->join('users', 'offers.user_id', '=', 'users.id')
                        ->addSelect('offers.*', 'users.is_premium')
                        ->orderBy('users.is_premium', 'desc');
    }


 public function filteredJobs()
    {
        $queryBuilder = Self::Query();
        
        // filter by available categories
        if (request('available_categories')) {
            $queryBuilder->filterByCategory();
        }
        

        // filter by available areas
        if (request('available_areas')) {
            $queryBuilder->filterByPref();
        }
        
        // filter the job that is in between this price
        if (request('pricerange')) {
            $queryBuilder->filterByPrice();
        }

        // Sort by Premium User( is_premium column at users table)
        $queryBuilder->orderByPremium();


        return $queryBuilder;
    }

Activity icon

Started a new conversation How To Sort Results By A Related Tables Column

hi,

I have a jobs table that has the user_id and a users table that has is_premium column. I want to sort the jobs table result by descending order based on the users.is_premium column. I am using some query scope to get the filtered result set( by a search filter), but stuck on this sorting part

here is my approach so far:

Jobs.php
---------------

   // relations
    public function pref(){

        return $this->belongsTo('App\Pref');
    }

    public function user(){

        return $this->belongsTo('App\User');
    }

   // query scopes

    public function scopeFilterByCategory($q)
    {
        return  $q->with('categories')->whereHas('categories', function ($query) {
            $query->whereIn('category_id', request('available_categories'));
        });
    }

    public function scopeFilterByPref($q)
    {
        return  $q->with('pref')->whereHas('pref', function ($query) {
            $query->whereIn('pref_id', request('available_areas'));
        });
    }


    public function filteredJobs()
    {
        $queryBuilder = Self::Query();
        
        // filter by available categories
        if (request('available_categories')) {
            $queryBuilder->filterByCategory();
        }
        

        // filter by available areas
        if (request('available_areas')) {
            $queryBuilder->filterByPref();
        }
        
        // filter the job that is in between this price
        if (request('pricerange')) {
            $queryBuilder->filterByPrice();
        }

        // Sort by Premium User( is_premium column at users table)

       // want to sort the result in desc order so that the userd.is_premium = 1 result 
       // set will show      first.
       // how to perform that 
      // $queryBuilder->orderBy('users.is_premium', 'desc'); // doesn't work

        return $queryBuilder;
    }

and form my controller I am returning result as below:

    public function index(Request $request)
    {

        $request->flash();

        $jobs = new JobOffer();
        $jobs = $jobs->filteredJobs()->paginate(15);
        return view('jobs.index', ['jobs' => $jobs]);
    }

Any help is highly appreciated. Thanks

Jun
23
2 years ago
Activity icon

Replied to Save And Update Multiple Rows In A Table

update: be sure to end the function block

{ } using proper curly braces, in your sample code it seems the closing '}' is missing

Activity icon

Replied to Save And Update Multiple Rows In A Table

try this:


public function insert(Request $request)
   {
     $user = Auth::user();
     foreach ($request->apports as $key => $v)
     {
       $data []  = [ 
            'user_id'=>$user,
            'name'=>$v,
            'min'=>$request->min [$key],
            'max'=>$request->max [$key] 
       ];
     // earlier you were trying to insert after the foreach loop. so it was only one record that gets stored
       $criteresperso = $user->criterespersos()->insert($data);
      //Criteresperso::insert($data);
     }
     
     return redirect()->route('bilans.index');

and if you found array to string conversion error, be sure to pass string as the input value instead of array

Activity icon

Replied to Permissions Question - Preventing Admin Account From Being Deleted By Other Admin Users

I am assuming that you have assigned the roles for a user using a role flag in your database

------------------------------------------------
id | name | email | user_role ( or may be a pivot table)
------------------------------------------------

why aren't you trying to write an accessor that will check if the targeted user has an admin role(the user to be deleted), something like:

if($user->is_admin){
   // just return , or don't allow the delete option in blade template
}

at your user's model

public function getIsAdminAttribute(){
    return $this->user_role == 1;  
       // considering user_role 1 = admin
       //  maybe 2 for manager_user
}
Jun
18
2 years ago
Activity icon

Started a new conversation Materilizecss Multiselect Is Not Updateing V-model Value

Hi,

I am attempting to use Materialize multi-select option with vue, but it does updated v-model value when selecting options from the select box. I have already checked this answer https://stackoverflow.com/questions/33704122/vuejs-materializecss-select-field But i don't want to separate the select field as a directive. Here is my code so far:

 <template>
                <div class="input-field col s10 offset-s1 m4">
                    <select multiple
                        v-model="search_param.available_categories"
                        name="available_categories[]" 
                    >
                      <option value="" disabled selected>Choose Categories</option>
                            <option 
                                v-for="industrial_category in industrial_categories" 
                                :value="industrial_category.id"
                            >{{ industrial_category.name.trim() }}</option>
                    </select>           
                </div>


<template>
<script>

    export default {
        data(){
            return {
                industrial_categories: null,
                search_param: {
                    freeword: '',
                    available_areas: [],
                    available_categories: []
                }
            }
        },
        methods:{
            // getting some data from database
            fetchAllCategories(){
                this.$http.get('/api/industrial-categories').then(response => {
                    this.industrial_categories = response.data.industrial_categories;

                let self = this
                    Vue.nextTick(function () {
                        $(self.$el).find('select').material_select();
                    })

                }, response => {
                    console.log(response);
                });

            }

        },
        created(){
            this.fetchAllPrefs();
            this.fetchAllCategories();

        }


    }

</script>
Jun
11
2 years ago
Activity icon

Replied to PROBLEM TO PRINT A VARIABLE

using the get() method at your query you are retrieving a collections of record. at your view you should loop through it and print the desired key from that object.

For a simpler example, try this


{{  $sales[0]->total_sale }} // if you are interested only for the first record to view

Alternative:
-----------------
@foreach($sales as $sale)

   {{ $sale->total_sales }}

@endforeach





May
29
2 years ago
Activity icon

Replied to Search Results Are Not Being Displayed.

@st8113 is right, you might need to try

$stores = DB::table('stores')->where('storename', 'like', '%{$search}%')->get();

// separates the variable
Activity icon

Replied to Laravel 5.4 Best Way To Prefill Form Inputs (edit Form)?

you can try:

<input name="name" type="text" value="{{ old('name') ? old('name') : $project->name }}" class="form-control" required>
Activity icon

Replied to Problems With Default(0)

you should not use both of

$guarded and $fillable at the same time, either $guarded or $fillable should be used.
May
12
2 years ago
Activity icon

Replied to Getting TokenMismatchException In VerifyCsrfToken.php Line 68 Sometime

hi, be sure to check if the csrf_token is being passed with the request, if you are using ajax request, it should be passed automatically by default in laravel.

May
09
2 years ago
Activity icon

Replied to Has Many Only Returning The First Record Though There Are Several.

try using

// to get a collection method should not be called as property, don't know if // there is an update on the L 5.4, but this should work

$category->notes();


May
07
2 years ago
Activity icon

Replied to Foreach Loop Posts Not Displaying Properly

Please watch some beginner level videos here, so you will be able to avoid such traps:

https://laracasts.com/series/laravel-from-scratch-2017

Activity icon

Replied to Foreach Loop Posts Not Displaying Properly

public function index()
    {
        $posts = Post::all();

        return view('post.manage')->with(['allposts' => $posts]);

// this will work, you were returning wrong view files
    }

Activity icon

Replied to Foreach Loop Posts Not Displaying Properly

try:


public function index()
    {
        $posts = Post::all();

        return view('home.index')->with(['allposts' => $posts ]);
    }

Activity icon

Replied to Foreach Loop Posts Not Displaying Properly

my reply should solve the problem, if not please paste your errors, so we will be able to help further.

Activity icon

Replied to Foreach Loop Posts Not Displaying Properly

I am assuming you are using index() method to return the related view first fetch all post by using:


function index(){

$allposts = Post::latest();
return view('your-view')->with(compact('allpost'));
}

May
03
2 years ago
Activity icon

Replied to Only Getting Last Record From Loop

You can re-factor your code as well:

$getDefects = []; // defining an empty to contain the result set

$a_project = Auditproject::where([
     'subid' => $this->loggedUserSubid,
     'contractorid' => $this->loggedUser,
     'projectid' => $request->proj_id 
])->get();
        
         foreach ($a_project as $a){
            $projectid=$a['projectid'];
            $snagid =$a['snagid'];
            $defectid =$a['defectid'];
            

// filling up the empty array with the result set
            $getDefects[] = SnagDefects::where([
            'snag_id' => ,$snagid,
            'defect_id'=>$defectid
      ])->get();   
           
}


           return $getDefects;

Activity icon

Replied to Only Getting Last Record From Loop

try this:

$getDefects = []; // defining an empty to contain the result set

$a_project = Auditproject::where('subid','=',$this->loggedUserSubid)->where('contractorid','=',$this->loggedUser)
                ->where('projectid','=',$request->proj_id)->get();
        
         foreach ($a_project as $a){
            $projectid=$a['projectid'];
            $snagid =$a['snagid'];
            $defectid =$a['defectid'];
            

// filling up the empty array with the result set
            $getDefects[] = SnagDefects::where('snag_id','=',$snagid)->where('defect_id','=',$defectid)->get();   
           
}


           return $getDefects;

Activity icon

Replied to How Do You Work With Two Tables That Doesn't Have The Same Eloquent Relationship In The Same Controller

in your Receiving Controller, you can try:

$receiving_data = Receiving::create([
         'product_id' => $request->get('product_id'),
         'product_id' => $request->get('supplier_id'),
         'unit' => $request->get('unit'),
         'serial_number' => $request->get('serial_number')

]);

$stocks = Stock::findOrFail($request->get('product_id'));
$stock->unit = $receiving_data->unit;  
// taking the unit value and saving into, if you want to add just add 
// $stock->unit = $stock->unit+$receiving_data->unit;
$stock->save();

I am assumming request as the data source

Apr
29
2 years ago
Activity icon

Replied to Your Requirements Could Not Be Resolved To An Installable Set Of Packages.

sorry I haven't seen your composer.json code, update the require section as follows:


"require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.3.*",
        "cartalyst/sentinel": "2.0.*",
        "nexmo/laravel": "^0.4.0",
    "laravel/socialite": "2.*"
    },

and then run

composer update 

composer dump-autoload

from your terminal

Activity icon

Replied to Your Requirements Could Not Be Resolved To An Installable Set Of Packages.

In your composer.json file,

find for the line

"laravel/socialite"

and specify v-2 like this

"laravel/socialite": "2.*",

then run

composer update
composer dump-autoload

this should fix your problem ( note that the latest version of socialite requires laravel-5.4, so we are downgrading to previous packages, v-2)

Activity icon

Replied to How To Pass Value From Js To Controller

you are already sending the ajax request to the route "/select2", if you still haven't define your route and it's handler controller

in your route.php

Route::post('/select2', '[email protected]');

// replace the controller and methodName as your definition goes 

and later in your Seletc2Controller.php ( App/http/controllers/select2Controller.php)

public function methodName(Request $request){
   dd( $request->all());  // you should see all of your ajax passed values
}
Apr
28
2 years ago
Activity icon

Replied to Database Migration Issues

Strange, you are still getting the same error. can you please check your database configuration( .env file or config/database.php ), and do you know if some event occurs and it runs some background program to seed some data on your application( it's a strong possibility now)when the migration runs.........

you can just try by using a simple migration file to see if the command runs successfully, a really too simple table migration file may be only with 2 columns.

php artisan migrate:refresh

Activity icon

Replied to Database Migration Issues

well.. just for quick debugging purpose, you can move all of the migration files except

create_accounts_table

// and 

create_users_table

and see if the command runs successfully, and track done the rest using this approach, it might take a little longer if your have lots of table on your database, but will save you from being depressed.

Activity icon

Replied to Database Migration Issues

do you have an existing row on your accounts table, it is not fair to use an id of 0 by the way. this way the foreign key should throw an exception.

Activity icon

Replied to Database Migration Issues

in that case you need to ensure that the migration sequence

234142324234242_create_accounts_table

must comes first before your user table

( I am assuming that you have added a foreign key on the account_id column in your user table)

Activity icon

Replied to Database Migration Issues

Are you seeding data at the same time ??

Apr
27
2 years ago
Activity icon

Replied to Accessing Property From An Array Of Records

hi, can you please show the view blade logic. For hints, if you haven't traverse through the collection by using a

@foreach($sellers as $seller)
     @foreach($seller as $single_seller)
                {{ $single_seller->email; }}  // should work 
@endforeach
@endforeach

if you don't want to get a collection and loop through it twice, you can just use the first() mehthod in your eloquent call

$sellers[] = \App\Seller::where('email', $sender->from)-first();
Activity icon

Replied to Laravel 5.3 - RegisterController And SQLSTATE[HY000]: General Error: 1364

Not sure though, but for debugging purpose, you can try by changing your column name form

username to user_name

// and your method, 

 protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'user_name' => $data['username'],
            'email' => $data['email'],
            'password' => bcrypt($data['password'])
        ]);
    }

don't forget to change the fillable property on your user model as well

protected $fillable = ['name', 'user_name', 'email', 'password'];

and hit the registration form to check if that works. Also you can try a die and dump

dd($data['username'])

on your create method, it is expected that you will get some value here, otherwise the validation should through an exception.

Hope it will help

Activity icon

Replied to Getting Problem In Login

@ershakti , if you are still struggling, you can use the following command on the terminal( be sure to enter into the project directory first)


php artisan route:list

this should provide you all of the route list and form the list you should find a route called:

/login , /logout or related route and it's handler function.

it seems the handler for login method stays on the trait:

 AuthenticatesAndRegistersUsers

Hope it helps.

Apr
25
2 years ago
Activity icon

Replied to Error In Compiling Less Files In Laravel Mix

@thoasty thanks a lot for your reply.

After some hour of research i have found that laravel-mix has some issue for using relative path.

As the example in the default sass/app.scss file, it doesn't refer to a file but ends with the directory.

// Bootstrap
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

this shorthand approach can only be used if and only if there exists a file with the same name prefixing with a '_'( underscore), e.g _bootstrap.scss

so for my case it doesn't work, since there was no file that follows the convention ( _bootstrap.less )

@import "public/limitless/assets/less/_bootstrap";

now i have solved this by using

mix
   .copy('resources/assets/limitless/assets/css/icons', 'public/css/icons', false)

   .copy('resources/assets/limitless/assets/js', 'public/assets/js', false)
   
   .js('resources/assets/js/app.js', 'public/js')

    .less('resources/assets/less/app.less', 'public/css')
    .options({
        processCssUrls: false
    });

of-course be sure to use

.options({
        processCssUrls: false
    });

otherwise it will generate issue for compiling relative fonts url.

Apr
24
2 years ago
Activity icon

Started a new conversation Error In Compiling Less Files In Laravel Mix

Hi,

I was trying to compile less files using laravel-mix. my assets is in the public folder, and it looks like as follows:

public/limitless/asset/less

|
---- _bootstrap/
|
---- bootstrap_limitless
|
---- components
|
---- core
|
----- _global

so I have created a less directory in my resources/assets and and a app.less file


resources/assets/less
|
----  app.less
|

and in my app.less file i have added the following lines:

@import "public/limitless/assets/less/_bootstrap";

( I was following the sass file at assets/sass/app.scss , which calls bootstrap form the node_modules in it)

and in my webpack.mix.js I have


mix.js('resources/assets/js/app.js', 'public/js')
   
//   .sass('resources/assets/sass/app.scss', 'public/css');

    .less('resources/assets/less/app.less', 'public/css');

and i am getting the following error:



 ERROR  Failed to compile with 3 errors                               9:12:18 AM

 error  in ./resources/assets/less/app.less

Module build failed: Can't resolve './public/limitless/assets/less/_bootstrap.less' in '/var/www/html/laravel54/resources/assets/less'
 @ /var/www/html/laravel54/resources/assets/less/app.less (line 7, column 0)
 near lines:
   
   @import "public/limitless/assets/less/_bootstrap";
    

 @ ./resources/assets/less/app.less 4:14-178
 @ multi ./resources/assets/js/app.js ./resources/assets/less/app.less

 error  in ./resources/assets/less/app.less

Module build failed: ModuleBuildError: Module build failed: Can't resolve './public/limitless/assets/less/_bootstrap.less' in '/var/www/html/laravel54/resources/assets/less'
 @ /var/www/html/laravel54/resources/assets/less/app.less (line 7, column 0)
 near lines:
   
   @import "public/limitless/assets/less/_bootstrap";
    
    at runLoaders (/var/www/html/laravel54/node_modules/webpack/lib/NormalModule.js:192:19)
    at /var/www/html/laravel54/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /var/www/html/laravel54/node_modules/loader-runner/lib/LoaderRunner.js:230:18
    at context.callback (/var/www/html/laravel54/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /var/www/html/laravel54/node_modules/less-loader/index.js:68:16
    at /var/www/html/laravel54/node_modules/less/lib/less/render.js:26:35
    at /var/www/html/laravel54/node_modules/less/lib/less/parse.js:62:33
    at ImportVisitor.finish [as _finish] (/var/www/html/laravel54/node_modules/less/lib/less/parser/parser.js:180:28)
    at ImportVisitor._onSequencerEmpty (/var/www/html/laravel54/node_modules/less/lib/less/visitors/import-visitor.js:35:14)
    at ImportSequencer.tryRun (/var/www/html/laravel54/node_modules/less/lib/less/visitors/import-sequencer.js:50:14)
    at /var/www/html/laravel54/node_modules/less/lib/less/visitors/import-sequencer.js:19:25
    at fileParsedFunc (/var/www/html/laravel54/node_modules/less/lib/less/import-manager.js:50:17)
    at /var/www/html/laravel54/node_modules/less/lib/less/import-manager.js:121:17
    at /var/www/html/laravel54/node_modules/less-loader/index.js:111:5
    at onResolved (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/Resolver.js:70:11)
    at loggingCallbackWrapper (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
    at afterInnerCallback (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/Resolver.js:138:10)
    at loggingCallbackWrapper (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (/var/www/html/laravel54/node_modules/tapable/lib/Tapable.js:181:46)
    at innerCallback (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/Resolver.js:125:19)
    at loggingCallbackWrapper (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
    at /var/www/html/laravel54/node_modules/tapable/lib/Tapable.js:283:15
    at /var/www/html/laravel54/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:38:4
    at loggingCallbackWrapper (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
    at afterInnerCallback (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/Resolver.js:138:10)
    at loggingCallbackWrapper (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (/var/www/html/laravel54/node_modules/tapable/lib/Tapable.js:181:46)
    at innerCallback (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/Resolver.js:125:19)
    at loggingCallbackWrapper (/var/www/html/laravel54/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
    at /var/www/html/laravel54/node_modules/tapable/lib/Tapable.js:283:15

 error  


what am i doing wrong, or what is the correct way, can you please explain

Thanks

Mar
18
2 years ago
Activity icon

Started a new conversation VeeValidation Errors In Parent And Child Componets

Hi all,

I have a large form and divided into several components, and for their fields validation i am using VeeValidation vue plugins. In the child it works and shows the validation errors. But before submitting i want to check for the validation on all of the input fields those are inside different child components. I am stuck here. Can anyone please help to achieve the goal / how can i check if each of the input field at child components have passed their validation rule form the parent components before submitting the form.

My patent component


                    <pet-info ref="pet" :formData="formData" @bithdate-set="updateBirthDate"></pet-info>
                    <card-info ref="card" :formData="formData" :cardForm="cardForm" :userId="user.id"></card-info>
                    <account-info v-if="!orders.is_logged_in" ref="accInfo" :formData="formData" :accInfo="accInfo"></account-info>

<!-- submit button trigger -->
<div class="row">
                        <div class="row col-xs-12">
                            <p class="bs-component text-right">
                                <button type="submit" @submit.prevent="sendPurchaseRequest" :disabled="errors.any()"
                                   :class="{'btn': true, 'btn-success': !errors.any(), 'btn-warning': requesting}">
                                    <i v-if="requesting" class="material-icons glyphicon-refresh-animate">autorenew</i>
                                    BUY NOW
                                </button>
                            </p>
                        </div>
                    </div>
 

and in my parent component i have defined these fields value into the data property

formData: {
                    // PetInfo
                    pet_name: '',
                    pet_birth_date: '',

        cardForm: {
                    number: '',
                    cvc: '',
                    name: '',
                    expiry: ''
                },
        accInfo: {
                    password: '',
                    password_confirmation: ''

                },

                }

here is the account-info child component

<div >

                    <!-- Account Info -->
                    <div class="col-xs-12 col-lg-7">
                        <div class="row">
                            <div class="col-xs-10 col-xs-offset-1 col-lg-11 col-lg-offset-0">
                                <div :class="{'form-group': true, 'label-floating': true,
                            'has-success': fields.passed('password'),
                            'has_error': vErrors.has('password'),
                            'is-focused': vErrors.has('password')}">
                                    <label :class="{'control-label': true }" for="password">Password</label>

                                    <input v-model="formData.password"
                                           type="password"
                                           name="password"
                                           id="password"
                                           v-validate="'required|min:6|confirmed'"
                                           :class="{'form-control': true, 'ime-off':true }"
                                    />
                                    <span v-show="!vErrors.has('password')" class="form-control-feedback">
                                        <i class="material-icons">done</i>
                                    </span>
                                    <span v-show="vErrors.has('password')" class="help-block">
                                    <strong class="text-danger">{{ vErrors.first('password') }} </strong>
                                </span>
                                </div>
                            </div>
                        </div>


                        <div class="row">
                            <div class="col-xs-10 col-xs-offset-1 col-lg-6 col-lg-offset-0">
                        <div :class="{'form-group': true, 'has_error': vErrors.has('password_confirmation')}">
                            <label for="password_confirmation" class="control-label">Confirm Password</label>
                            <input
                                    v-validate="'required'"
                                    type="password"
                                    class="form-control"
                                    id="password_confirmation"
                                    name="password_confirmation"
                                    v-model="formData.password_confirmation">
                        </div><!--end form group-->
                       </div>
                       </div>

                    </div>
                </div>

Note that in my app.js i have configured the errorBag errors to vErrors to avoid some conflicts. how can i check if each of the input field at child components have passed their validation rule form the parent components before submitting the form ?