Kaustubh

Kaustubh

Devloper at MInSysT Consulting Pvt. Ltd.

Member Since 2 Years Ago

Mumbai

Experience Points
8,540
Total
Experience

1,460 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
30
Lessons
Completed
Best Reply Awards
3
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 2
8,540 XP
Oct
30
11 months ago
Activity icon

Started a new conversation Multiple State Value Not Working In VUEX

Hi

This is my vuex (userStore.js) page

const state = {
    roles:null,
    authUser:null
}
const mutations  = {
    SET_AUTH_USER(state,userObj){
        state.authUser = userObj
    },
    SET_USER_ROLE(state,userRole){
        state.roles = userRole      
    }
}
const actions = {
    setUserObject :({commit},userObj) => {
        commit('SET_AUTH_USER',userObj)
    },
    setUserRoles :({commit},userRole) => {
        commit('SET_USER_ROLE',userRole)
    }
}
export default {
    state, mutations, actions
}

When i fetch data and dispatch to the sidebar page, and console store i get output like this sidebar.vue

console.log(this.$store.state.userStore)
// OUTPUT
// {__ob__: Observer}
// authUser: "NqStDm8ol3QGtoh0hzL7yhC3NP3HV0ktYKmYHI8TNiCjG4T4tLlv3pOEWFdA5CEh"
// roles: Array(3) 

console.log(this.$store.state.userStore.roles)
// (3) [{…}, {…}, {…}, __ob__: Observer]

console.log(this.$store.state.userStore.authUser)
// "NqStDm8ol3QGtoh0hzL7yhC3NP3HV0ktYKmYHI8TNiCjG4T4tLlv3pOEWFdA5CEh"

But Problem comes when i console it in dashboard or any other page i get output null in roles and value in authUser like given below

console.log(this.$store.state.userStore)
// OUTPUT
// {__ob__: Observer}
// authUser: "NqStDm8ol3QGtoh0hzL7yhC3NP3HV0ktYKmYHI8TNiCjG4T4tLlv3pOEWFdA5CEh"
// roles: Array(3)

console.log(this.$store.state.userStore.roles)
// null

console.log(this.$store.state.userStore.authUser)
// "NqStDm8ol3QGtoh0hzL7yhC3NP3HV0ktYKmYHI8TNiCjG4T4tLlv3pOEWFdA5CEh"
Activity icon

Started a new conversation Define Multiple Variable In VUEX Mutation

store.js

import Vue from 'vue';
import Vuex from 'vuex';
import userStore from './user/userStore.js';
import VuexPersist  from "vuex-persistedstate";
Vue.use(Vuex)
const debug = process.env.NODE_ENV !== 'production'


const vuexLocalStorage = new VuexPersist({
  key: 'vuex', // The key to store the state on in the storage provider.
  storage: window.localStorage, // or window.sessionStorage or localForage
})

export default new Vuex.Store({
modules:{
    userStore,
    plugins: [vuexLocalStorage.plugin]
},

strict:debug
})

userStore.js

const state = {
    authUser:null,
    roles:null
}
const mutations  = {
    SET_AUTH_USER(state,userObj){
        state.authUser = userObj
    },
    SET_USER_ROLE(state,userRole){
        state.roles = userRole      
    }
}
const actions = {
    setUserObject :({commit},userObj) => {
        commit('SET_AUTH_USER',userObj)
    },
    setUserRoles :({commit},userRole) => {
        commit('SET_USER_ROLE',userRole)
    }
}
export default {
    state, mutations, actions
}

Sidebar.vue

created(){
    this.getRoles();
},
methods: {
    getRoles(){
        var _this = this
        _this.roles_data = response.data
        _this.$store.dispatch('setUserRoles',_this.roles_data)
        _this.fetch_roles()
    }
    fetch_roles(){
        console.log(this.$store.state.userStore.roles)
        // OUTPUT
        // (3) [{…}, {…}, {…}, __ob__: Observer]

        console.log(this.$store.state.userStore)
        // OUTPUT
        // {__ob__: Observer}
        // authUser: "NqStDm8ol3QGtoh0hzL7yhC3NP3HV0ktYKmYHI8TNiCjG4T4tLlv3pOEWFdA5CEh"
        // roles: Array(3)      
    }
}

Dashboard.vue

created(){
    console.log(this.$store.state.userStore.roles)
    // OUTPUT
    // null

    console.log(this.$store.state.userStore)
    // OUTPUT
    // {__ob__: Observer}
    // authUser: "NqStDm8ol3QGtoh0hzL7yhC3NP3HV0ktYKmYHI8TNiCjG4T4tLlv3pOEWFdA5CEh"
    // roles: Array(3)
}

hi I am working on vuex to store user roles access. I am storing two variable in store 1) authUser 2) roles. authUser store user token and roles store user roles array. When i fetch role from api, i dispatch roles to _this.$store.dispatch('setUserRoles',_this.roles_data). When i console in sidebar i get output like this

console.log(this.$store.state.userStore.roles)
(3) [{…}, {…}, {…}, __ob__: Observer]

console.log(this.$store.state.userStore)
{__ob__: Observer}
authUser: "NqStDm8ol3QGtoh0hzL7yhC3NP3HV0ktYKmYHI8TNiCjG4T4tLlv3pOEWFdA5CEh"
roles: Array(3)

But when i console same thing in dashboard in created function it return roles null

console.log(this.$store.state.userStore.roles)
null

console.log(this.$store.state.userStore)
{__ob__: Observer}
authUser: "NqStDm8ol3QGtoh0hzL7yhC3NP3HV0ktYKmYHI8TNiCjG4T4tLlv3pOEWFdA5CEh"
roles: Array(3)

Am i missing something ?? or its a bug

Oct
25
11 months ago
Activity icon

Started a new conversation Merging Nested Array Boolean Values

I have an array Output something like this and i want to merge them by page_id

    Object
        data: Array(2)
        0: Array(3)
            0: {page_id: 1, view: true, edit: true, update: true, delete: true}
            1: {page_id: 2, view: true, edit: false, update: false, delete: true}
            2: {page_id: 3, view: true, edit: false, update: false, delete: false}
            length: 3
            __proto__: Array(0)
        1: Array(3)
            0: {page_id: 1, view: false, edit: false, update: false, delete: true}
            1: {page_id: 2, view: false, edit: false, update: false, delete: true}
            2: {page_id: 3, view: false, edit: false, update: false, delete: false}
            length: 3
            __proto__: Array(0)
        .
        .
        .
        .
        
        length: 2

I need Output something like this

    result[0] => {
        0: {page_id: 1, view: true, edit: true, update: true, delete: true}
        1: {page_id: 2, view: true, edit: false, update: false, delete: true}
        2: {page_id: 3, view: true, edit: false, update: false, delete: false}          
    }

Thanks in advance

Oct
24
11 months ago
Activity icon

Started a new conversation Merge Multiple Array Values

I have 1 and more than 1 array and i have to merge them.

arr[0] => { view:true, edit:true, delete:false, add:false }
arr[1] => { view:false, edit:true, delete:false, add:false }
arr[2] => { view:true, edit:true, delete:true, add:false }

I need output like this

result = { view:true, edit:true, delete:true, add:false }

if any one of object have true value it should replace it to true from false

Thanks in advance

Aug
28
1 year ago
Activity icon

Started a new conversation Dropdown Model-list-select :list Not Working In Popup Modal

Hi,

i used dropdown input in popup model and assigned array value in :list="conopt" when i select the option i get the country name, but i was expecting for array which has id, name, sortname.

When i put that dropdown outside popup model i got my expected result. But problem is that i want that result in popup model.

// USING Dropdown List in Popup Modal (Not Working as Expected)

<div>
    <b-modal title="Add Supplier" hide-footer size="lg" v-model="largeModal" @ok="largeModal = false" style="width: 140%; margin: auto;">
    <model-list-select :list="conopt" class="form-control"
        option-value="country_name"
        option-text="country_name"
        v-model="con"
        @input="state">
    </model-list-select >
</b-modal>
</div>

<script type="text/javascript">
    state(conopt){
      console.log(conopt) // Result India (Expecting array output)
    }
</script>

USING Dropdown List outside Popup Modal (Working as Expected)

<div>
    <model-list-select :list="conopt" class="form-control"
        option-value="country_name"
        option-text="country_name"
        v-model="con"
        @input="state">
    </model-list-select >
</div>

<script type="text/javascript">
    state(conopt){
      console.log(conopt)
        /*
        GETTING EXPECTED RESULT
        {__ob__: Observer}
            country_name:"India"
            id:"45"
            phonecode:"91"
            sortname:"IN"
        */
    }
</script>
Aug
06
1 year ago
Activity icon

Started a new conversation SSL Problem Treating Www And Non Www Different

I have windows server and have domain of godaddy. I took SSL from godaddy and apply on my server. My domain gets secure by SSL but problem come when, i redirect from https://www.example.com and logged in it shows dashboard but when i change url to https://example.com it redirect me to login page.

Here is my VHOST file

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "C:/mcpluat/xampp/htdocs/project/public"
    ServerName www.example.com
    ServerAlias example.com
    
    RewriteEngine on
    
    RewriteCond %{SERVER_PORT} 80  
    RewriteRule ^(.*)$ https://www.example.com/ [R,L]

    <Directory "C:/mcpluat/xampp/htdocs/project/public">
      Options Indexes FollowSymLinks Includes ExecCGI
       AllowOverride All
       Require all granted
    </Directory>
</VirtualHost>

.HTACCESS file

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Everything is working perfectly but why it is treating www.example.com and example.com a different domain

Thanks in advance

Jul
12
1 year ago
Activity icon

Started a new conversation Undefined Index Driver

Hi, I have two different database and i connect to another database to get the data. It works fine but when i continuously press refresh it throws Undefined Index Driver. below is my code

CONNECTION TO ANOTHER DATABASE

  // Disconnect old connection and connect to other database
  $dm = app("Illuminate\Database\DatabaseManager");
  $dm->disconnect();
  $model = Config::set("database.connections.pgsql", [
      'driver'    => 'pgsql',
      'host'      => '127.0.0.1',
      'port'      => '5432',
      'database'  => 'jobseeker',
      'username'  => 'postgres',
      'password'  => 'root',
      'charset'   => 'utf8',
  ]);
  DB::setDefaultConnection('pgsql');
  DB::reconnect($model);
  //End

RE CONNECTION TO CURRENT DATABASE

    // Disconnect old connection and connect to original database
    $model = Config::set("database.connections.".env('DB_CONNECTION'), [
        'driver'    => env('DB_CONNECTION'),
        'host'      => env('DB_HOST'),
        'port'      => env('DB_PORT'),
        'database'  => env('DB_DATABASE'),
        'username'  => env('DB_USERNAME'),
        'password'  => env('DB_PASSWORD'),
        'charset'   => 'utf8',
    ]);
    DB::setDefaultConnection(env('DB_CONNECTION'));
    DB::reconnect($model);
    //End

The reason behind the error is, i called credential from env file and on refresh it sometime dosent get value from env. I dont want to use hardcore values to reconnect to current database. Is there any solution for this

May
21
1 year ago
Activity icon

Replied to Copy Files From URL To Server Public Folder

thanks @lostdreamer_nl

i got the solution

  file_put_contents(public_path('datafiles\APPL').'/'.$resume, fopen(REQUEST('cand_resume_url'), 'r'));
Activity icon

Started a new conversation Copy Files From URL To Server Public Folder

Hi I have two project in which one project contains files and another one dont have file. I want to copy the file from one server to another server.

Server 1 URL = http://localhost/jobseeker/public/datafiles/APPL/JOBSEEKER_trOoH.pdf

Server 2 URL = http://localhost/recruiter/public/

I want to copy server1 file in server2 public folder

    $file1 = REQUEST('cand_resume_url');
    $file2 = public_path('datafiles\APPL');
    File::move($file1, $file2);

I used Copy, Move but it throwing error

The file "http://localhost/mwayhire_jobseeker/public/datafiles/APPL/JOBSEEKER_trOoH.pdf" does not exist

May
10
1 year ago
Activity icon

Started a new conversation Queue Sending All Mails To Last Recipient

Hi There, I am currently facing an issue in queue mails. I made a queue table and it works perfectly when i send email to one person, but the issue comes when i fetch all records from table and foreach each of them and send mail to each recipient, It sends all the emails to the last recipient of the record. When i send email without queue it works perfectly.

for eg. i have two records in table 1st has [email protected] and another one has [email protected], when i use queue it send both emails to [email protected] and not to [email protected]

            // Daily Reports to BUSINESS HEAD
            $business = Business::where('b_daily',1)->select('business_name','b_email_id')->get();
            foreach ($business as $bus){
                dispatch(new SendEmailReports($bus->b_email_id));
            }

Please let me know if i am missing something.

Mar
20
1 year ago
Activity icon

Replied to Fetch Auth::user()->name From Database

actuall i am appending the response on ajax success

$("#chat-section ul").append('<li><div class="left-chat"><img src="https://images.g2crowd.com/uploads/product/image/large_detail/large_detail_1508920769/chatbotsbuilder.png"><p>'+data+'</p></div></li>');

The 'data' contain this output 'your name is {!! auth::user()->name !!}'
Mar
19
1 year ago
Activity icon

Started a new conversation Fetch Auth::user()->name From Database

Hi I have query table

id  |       query       |           output
1   |   What is my name |   your name is {!! auth::user()->name !!}

when i fetch data in blade i get this output your name is {!! auth::user()->name !!}

but i want your name is "USER NAME"

Feb
15
1 year ago
Activity icon

Replied to Eloquent Relationship Not Working

@arthurvillar i followed your method but Still not working, I even changed foreign key name

Activity icon

Replied to Eloquent Relationship Not Working

@Dexterr I think that will not affect. I dont know why its not Joining two tables

Activity icon

Replied to Eloquent Relationship Not Working

I just updated

Activity icon

Started a new conversation Eloquent Relationship Not Working

Hi There I just stucked on Eloquent Relationship. The Two table are not joining. I am getting this error SQLSTATE[42703]: Undefined column: 7 ERROR: column "quantity" does not exist LINE 1: select "quantity" from "mi_cmp_product" where "mi_cmp_produc... ^ (SQL: select "quantity" from "mi_cmp_product" where "mi_cmp_product"."id" is null and "product_id" = ABC3408804)

There are Two Table 1) Company Product & 2) Shop Inventory

  1. Company Product has product_id(PK)
  2. Shop Inventory has product_id(FK)

Company Product Model

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;

class CmpProduct extends Model
{
    protected $table='mi_cmp_product';
    protected $fillable=['product_id','regcity_code','company_id','category_id','sub_category_id','brand_id','hsn_id','tax_gst_id','variant_id','unit_id','alt_product_id','product_name','product_desc','product_barcode_symbol','product_alert_qty','product_track_req','product_tax_method','product_cf1','product_cf2','product_cf3','specification','lastupdated_by','lastupdated_datetime'];

    public function ShopInventory(){
        return $this->hasMany('App\ShopInventory', 'product_id', 'product_id');
    }
}

Shop Inventory Model

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;

class ShopInventory extends Model
{
    protected $table='mi_estshop_inventory';
    protected $fillable=['regcity_code','company_id','product_id','est_shop_id','unit_id','quantity','last_pur_price'];

    public function CmpProduct(){
        return $this->belongsTo('App\CmpProduct', 'product_id');
    }

    public function get_quantity($id)
    {
        $quantity = $this->CmpProduct()->where('product_id',$id)->pluck('quantity')->first();
        return $quantity;
    }
}

Controller

 $shop = new ShopInventory;
 return view('return_purchase',compact('shop');

View

<input type="text" name="available_qty" id="available_qty" value="{{ $shop->get_quantity($pur_items->product_id) }}">

Am i missing something??

Thanks & Regards

Jan
12
1 year ago
Activity icon

Replied to Is My Laravel Project Has Been Hacked Or Bug

Just now i found that Every files in xampp on Amazon Server has been affected

Activity icon

Started a new conversation Is My Laravel Project Has Been Hacked Or Bug

I had deployed my laravel project on Amazon Server and i recently found some extra php line of code auto generated in every files of laravel framework. I don't know is it virus or bug or it has been hacked. I have attach a sample screenshot below of config/view.php file

https://i.stack.imgur.com/jlG8h.jpg

Jan
02
1 year ago
Activity icon

Started a new conversation How Sync Database From Remote To Server Database

Hi I am creating an application in which every user has application install at their remote system. When the user gets connected to internet his local system database will be sync to main server database.

I dont know how to sync database from local to server.

Nov
15
1 year ago
Activity icon

Started a new conversation Select Table And Count Rows From Another Table Whose Seen Is 0

Here i want to fetch post table and i want to count records on postConversation table where post.id = postConversation.PostId where seen = 0. but in below query i get the record of all whose seen is 0 & 1, but in my case i want to fetch those row whose seen is 0

Post Table (post) id | title | text | hasImage | img_path | mentorid | menteeid 1 Title1 ABC 0 1113.png 12 11

Post Conversation Table (postConversation) id | PostId | conv | sender | receiver | seen | sen_del | rec_del 1 1 ABC 11 12 1 0 0 2 1 XYZ 12 11 1 0 0 3 1 ZCX 11 12 0 0 0 4 1 PAQ 11 12 0 0 0

$discussPosts = DB::table('post')->leftJoin('postConversation', 'post.id', '=', 'postConversation.Did') ->select('post.*', DB::raw('count(postConversation.Did) as postConversationCount')) ->groupBy('post.id') ->where('mentorid',Auth::user()->id) ->where('menteeid',$userid) ->get(); dd($discussion) //Result

Collection {#478 ▼ #items: array:4 [▼ 0 => {#476 ▼ +"id": 1 +"title": "Title1" +"text": "ABC" +"hasImage": "1" +"img_path": "1113.png" +"mentorid": "12" +"menteeid": "11" +"status": "1" +"created_at": "2017-11-16 11:16:13" +"updated_at": "2017-11-16 11:16:13" +"postConversationCount": 4

Nov
13
1 year ago
Activity icon

Replied to Dynamic Routes

route can be anything like register, home, { AnyCommunutyName } etc.

Activity icon

Replied to Dynamic Routes

@RamjithAp i want to redirect to any other defined route if not found in table. such as if i write http://localhost/community/public/login it first check in community controller and if not found the default login route will be called

Activity icon

Started a new conversation Dynamic Routes

Route

Route::get('{communityName}', '[email protected]')->name('test');

Controller

public function test($CommunityName)
{
    $community = Community::where('communityName',$CommunityName)->get();
    if(!$community)
    {
        return redirect()->route($community);
    }

    return view('layouts.Community',compact('community'));
}

Here i want to redirect to community page if it is present in table and if that name not present in table then it should redirect to specific route

for eg. // Should redirect to community page http://localhost/community/public/DUMMYCOMMUNITY

// Should redirect to login page http://localhost/community/public/login

But this process is going in an infinite loop. is there any best way to achive this

Nov
01
1 year ago
Activity icon

Replied to CSRF Token Mismatch

HTML FORM

                <form role="form" method="POST" action="{{ route('CommunityRegister') }}" id="form1">
                <input type="hidden" value="register" name="tab" />
                <input type="hidden" name="communityName" id="communityName" value="{{ $name }}">
                <input type="hidden" name="communityToken" id="communityToken" value="{{ $token }}">
                {{ csrf_field() }}

                    <div class="form-group">
                        <label for="email">Community Name:</label>
                        <input id="communityName1" type="text" class="form-control" name="communityName1" value="{{ $name }}" autocomplete="off" required disabled="">
                    </div>

                    <div class="form-group">
                        <label for="email">Community Token:</label>
                        <input id="communityToken1" type="text" class="form-control" name="communityToken1" value="{{ $token }}" autocomplete="off" required disabled="">
                    </div>

                    <div class="form-group">
                        <label for="email">First Name:</label>
                        <input id="fname" type="text" class="form-control" name="fname" value="{{ old('fname') }}" autocomplete="off" required>
                        @if ($errors->has('fname'))
                            <span>
                              <small style="color: #e05d6e;">{{ $errors->first('name') }}</small>
                            </span>
                        @endif
                    </div>

                    <div class="form-group">
                        <label for="email">Last Name:</label>
                        <input type="text" name="lname" id="lname" class="form-control" value="{{ old('lname') }}" autocomplete="off" required>
                        @if ($errors->has('lname'))
                            <span>
                              <small style="color: #e05d6e;">{{ $errors->first('lname') }}</small>
                            </span>
                        @endif
                    </div>

                    <div class="form-group">
                        <label for="email"> Mobile or Email <small style="color: #e05d6e;">(Email compulsory if not from community link)</small>:</label></br>
                        <input id="mobile" type="text" class="form-control" name="mobile" value="{{ old('mobile') }}" autocomplete="off" style="width: 100% !important">
                        @if ($errors->has('mobile'))
                            <span>
                              <small style="color: #e05d6e;">{{ $errors->first('mobile') }}</small>
                            </span>
                        @endif
                    </div>

                    <div class="form-group">
                        <label for="password">Password: </label>
                        <input id="pass" type="password" name="pass" class="form-control" autocomplete="off" required>
                        @if ($errors->has('pass'))
                            <span>
                              <small style="color: #e05d6e;">{{ $errors->first('pass') }}</small>
                            </span>
                        @endif
                    </div>
                    
                    <input type="submit" name="signup" value="Sign Up & Login" class="btn btn-primary btn-block active" aria-pressed="true">

                </form>

CONTROLLER

public function CommunityRegister(Request $req)
{
    $input = $req->all();
    $mobile = REQUEST('mobile');
    if(is_numeric($mobile)){
        $has_mobile = 1;
        $validator = Validator::make($input, [
            'fname' => 'required|string|max:20',
            'lname' => 'required|string|max:20',
            'mobile' => 'required|numeric|unique:users',
            'pass' => 'required|string|min:6',
        ]);
    }else{
        $has_mobile = 0;
        $validator = Validator::make($input, [
            'fname' => 'required|string|max:20',
            'lname' => 'required|string|max:20',
            'mobile' => 'required|string|email|max:50|unique:users',
            'pass' => 'required|string|min:6',
        ]);
    }

    if($validator->passes())
    {
        $fname = REQUEST('fname');
        $lname = REQUEST('lname');
        $mobile = REQUEST('mobile');
        $password = bcrypt(REQUEST('pass'));
        $emailtoken = str_random(25);

        $ids = DB::table('users')->orderBy('id','desc')->pluck('id')->first();
        $count = $ids + 1;
        $username = strtolower($fname.$count);
        $name = $fname.' '.$lname;

        $data = array(
            'name' => $name,
            'fname' => $fname,
            'lname' => $lname,
            'username' => $username,
            'mobile' => $mobile,
            'password' => $password,
            'emailtoken' => $emailtoken,
            'has_mobile'   => $has_mobile,
            'phone_verified' => TRUE,
        );
        DB::table('users')->insert($data);
        $userid = DB::table('users')->where('mobile',$mobile)->pluck('id')->first();
        $cid = DB::table('community')->where('name',REQUEST('communityName'))->where('token',REQUEST('communityToken'))->pluck('id')->first();

        $endDate = DB::table('community')->where('id',$cid)->pluck('endDate')->first();
        if(date('Y-m-d') <= $endDate)
        {
            $status = 1;
        }
        else{
            $status = 0;                
        }

        $communitydata = array(
            'Cid'       =>  $cid,
            'Uid'       =>  $userid,
            'admin'     =>  0,
            'status'    =>  $status,
        );

        DB::table('community_user')->insert($communitydata);

        $credentials = array(
            'mobile' => REQUEST('mobile'),
            'password' => REQUEST('pass'),
        );

        if (Auth::attempt($credentials)) {
            return redirect()->route('start');
        }
        else{
            return redirect()->back()->with('status','Something Went Wrong');
        }
    }

    return redirect()->back()->withErrors($validator)->withInput();
}
Activity icon

Replied to CSRF Token Mismatch

Within 10 min. It throws error even when i am not logged in.

Activity icon

Started a new conversation CSRF Token Mismatch

I am facing problem on a form submission. When i open a form and submit it after some time it throws token mismatch exception. How can i handle this exception without redirect, i just want to submit the data in one attempt

Sep
05
2 years ago
Sep
04
2 years ago
Activity icon

Replied to How To Read Barcode Data From Barcode Scanner

@ModestasV i didnt get it, I actually want to know how does it happen that when I scan the barcode using barcode scanner, how it will automatically put in my html textbox

Is there any specific package for that? ....i am new to it

Activity icon

Started a new conversation How To Read Barcode Data From Barcode Scanner

Hi Guys

I generated barcode successfully, but now i want to read barcode from the barcode reader device (i dont have right now) but i want to know that is there any package which, fetch the data from that barcode device.

From reading barcode i will be able to display full details on user system.

Thanks in advance

Aug
29
2 years ago
Activity icon

Replied to How To Get Table And Text Value Of Phpword

@bashy is there any package which convert doc, docx or any other file to PDF

Aug
21
2 years ago
Activity icon

Started a new conversation How To Use Pg_unescape_bytea

I successfully stored file in database (bytea datatype), but when i try to retrive my file it throws error

Method Illuminate\Support\Collection::__toString() must return a string value

My controller

public function index()
{
    $img = DB::table('images')->pluck('file');
    $decode = pg_unescape_bytea($img);
    dd($decode);
    return view('home',compact('decode'));
}

// To store file in database

public function save(Request $req)
{
    $resume = Input::file('file');
    $extenstion = file_get_contents($resume);
    $file = pg_escape_bytea($extenstion);
    $data = array('file' => $file); 
    DB::table('images')->insert($data);
    return redirect()->back();
}
Aug
16
2 years ago
Activity icon

Started a new conversation How To Pass Variable In Validation Rule

Hi guys,

I want to validate text field if Commission amount is less than 4.5% on Salary

<input type="text" id="salary" name="salary">
<input type="text" id="commission" name="commission" placeholder="Amt should be >= 4.5% on salary">

public function hrCJPsave(Request $req)
{  
     $salary => REQUEST('salary');
     $commission = $salary*4.5/100;

    $input = $req->all();
    $validator = Validator::make($input, [
        'salary'            =>  'required|max:2',
        'commission'        =>  'required|min:$commission'            
    ]);
}

How can i pass variable in validator

Aug
15
2 years ago
Activity icon

Started a new conversation Old Value In Select Option

Hi,

I have a form in which there is a select option for Gender, what i want to achive is if my validator fails then its get redirect back with old inputs. but i dont know how to populate my select option with old value.

<select id="gender" name="gender">
    <option value="male">Male</option>
    <option value="female">Female</option>
</select>

I have another question. I have user table in which user has role. When admin update user record his role dropdown should contain all roles but the selected role should be his role which is in his record

Role Dropdown -  HR Manager   ----> selected ..as stored in database
                 Admin
                 Superadmin
Aug
09
2 years ago
Activity icon

Started a new conversation Cant Foreach Array In Blade

how i can send null data or default value of data from controller here is my code Controller

public function recruiterDet()
{
    $auth = Auth::User()->id;
    $miRec = Recruiters::where('userid',$auth)->first();

    if(!empty($miRec))
    {
        return view('RcDetailMainpage',compact('miRec'));
    }

here i m try to fill some default value so i can foreach it in blade

    else{
        $miRec = collect([['cmpname'=>NULL,'Address'=>NULL],]);
        return view('RcDetailMainpage',compact('miRec'));
    }
}

Blade View

@foreach($miRec as $a)
<input type="text" class="form-control" id="cmpname" name="cmpname" value="{{ $a->cmpname }}">
<input type="text" class="form-control" id="Address" name="Address" value="{{ $a->Address }}">
<input type="submit" value="Update">
@endforeach 

i don't want to use if else condition in blade because i have lots of form if i use if else then it will increase 2 time in size in blade

Aug
01
2 years ago
Activity icon

Replied to Redirect Different Views Base On Roles

..\vendor\laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUsers.php

protected function authenticated(Request $request, $user)
{
    if($user->id_role === 1) {
        return redirect()->intended(route('superuser.index'));
    }
    elseif($user->id_role === 2) {
        return redirect()->intended(route('admin.index'));
    }
    return redirect()->intended(route('user.index'));
}
Jul
31
2 years ago
Activity icon

Replied to How To Handel BadMethodCallException

Thanks @DanielBanciulea for giving your precious time

Activity icon

Started a new conversation Sql Injection

View

<div class="panel-body">
    @foreach($pageLi as $li)
        <a href="{{ url('/userlogin',array($li->p_id)) }}">{{ $li->p_name }}</a>
    @endforeach
</div>

Url

http://localhost/test/public/userlogin/3

Route

Route::get('/userlogin/{id}',['uses' => '[email protected]', 'as' => 'login.get']);

Controller

public function userlogin($id)
{
    $Task = App\Task::where('userid',$id)->first();
    return view('task', ['task'=>$task]);
}

is there any way to prevent sql injection from url and should i use anchortag in form & {{ csrf_field() }}

Activity icon

Replied to How To Handel BadMethodCallException

@DanielBanciulea nothing happens

(1/1) BadMethodCallException Method [save] does not exist.

Activity icon

Replied to How To Handel BadMethodCallException

<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that should not be reported.
     *
     * @var array
     */
    protected $dontReport = [
        \Illuminate\Auth\AuthenticationException::class,
        \Illuminate\Auth\Access\AuthorizationException::class,
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
        \Illuminate\Session\TokenMismatchException::class,
        \Illuminate\Validation\ValidationException::class,
    ];

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Exception  $exception
     * @return void
     */
    public function report(Exception $exception)
    {
        parent::report($exception);
    }

    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $exception
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $exception)
    {
        if ($exception instanceof BadMethodCallException) {
            return response()->view('errors/ControllerNotFound');
        }
        return parent::render($request, $exception);
    }

    /**
     * Convert an authentication exception into an unauthenticated response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Illuminate\Auth\AuthenticationException  $exception
     * @return \Illuminate\Http\Response
     */
    protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }

        return redirect()->guest(route('login'));
    }
}
Activity icon

Replied to How To Handel BadMethodCallException

I want to handel BadMethodCallException and want to redired to Controller not found page if there is no controller.

Here is dd($exception)

BadMethodCallException {#215 ▼
  #message: "Method [save] does not exist."
  #code: 0
  #file: "C:\xampp\htdocs\lv54\vendor\laravel\framework\src\Illuminate\Routing\Controller.php"
  #line: 82
  trace: {▶}
}

and i am using 5.4 version

Activity icon

Replied to How To Handel BadMethodCallException

Its not working

public function render($request, Exception $exception)
{
    if ($exception instanceof BadMethodCallException) {
        return response()->view('errors/ControllerNotFound');
    }
    return parent::render($request, $exception);
}
Activity icon

Started a new conversation How To Handel BadMethodCallException

I want to redirect to a Controller Not Found view if BadMethodCallException occours

Jul
28
2 years ago
Activity icon

Started a new conversation How To Pass Function Name From Route Database Query

My Page Table

--------------------------------------------
    ID    |      Page     |    FunctionName    
--------------------------------------------
     1    |     Home      |    home        
     2    |    Welcome    |    wel

Here What i want to achive ---------------->

If user click on link, a page id will pass in route.

e.g. localhost/test/public/page/1

I want to write query in web.php and want to pass $function in controller function. So $function will change everytime whenever there will be new page ID

Route (Web.php)

$function = DB::table('page')->where('id',$id)->pluck('FunctionName');

Route::get('/page/{id}',['uses' => '[email protected]'$function]);
Jul
26
2 years ago
Activity icon

Replied to Update Data Using Array

Thanks @Snapey

public function UpdatePermission(Request $req)
{
    $input = $req->all();
    $i = 0;
    $count = count($input['roleid']);
    while($i < $count){

        $data[] = array(
            'per_id' => $input['perid'][$i],
            'per_roleid' => $input['roleid'][$i],
            'per_pageid' => $input['pageid'][$i],
            'view' => $input['view'][$i],
            'add' => $input['add'][$i],
            'edit' => $input['update'][$i],
            'delete' => $input['delete'][$i],
            
        );
        $i++;
    }

    $j = 0;
    $count1 = count($input['roleid']);
    while($j < $count1){
        DB::table('permission')->where('per_id',$data[$j]['per_id'])->update($data[$j]);
        $j++;
    }

    return redirect()->back();
}
Activity icon

Started a new conversation Update Data Using Array

I want to update multiple rows in Permission Table. I have permission id in array but i am unable to use where clause in query.

I want to use permissionid in where clause and the permission id is in array of data.

I can insert new records using array but i am finding difficulty to update using array.

Here is my controller

public function UpdatePermission(Request $req)
{
    $input = $req->all();
    $i = 0;
    $count = count($input['roleid']);
    while($i < $count){

        $data[] = array(
            'permissionid' => $input['perid'][$i],
            'per_roleid' => $input['roleid'][$i],
            'per_pageid' => $input['pageid'][$i],
            'view' => $input['view'][$i],
            'add' => $input['add'][$i],
            'edit' => $input['update'][$i],
            'delete' => $input['delete'][$i],
        );
        $i++;
    }

    // dd($data);
    
    DB::table('permission')->whereIn('per_id',$data['permissionid'])->update($data);
    return redirect()->back();
}

Here is my $data[] array

array:3 [▼
  0 => array:7 [▼
    "permissionid" => "6"-------------------> I want to use Permission Id in where clause
    "per_roleid" => "4"
    "per_pageid" => "1"
    "view" => "on"
    "add" => "on"
    "edit" => "on"
    "delete" => "off"
  ]
  1 => array:7 [▼
    "permissionid" => "7"-------------------> I want to use Permission Id in where clause
    "per_roleid" => "4"
    "per_pageid" => "2"
    "view" => "on"
    "add" => "off"
    "edit" => "off"
    "delete" => "off"
  ]
  2 => array:7 [▶]
]
Activity icon

Replied to How To Pass Checkbox Value 0 If Not Checked And 1 If Checked Using Array.

Thanks @Snapey you saved my day... :)

thank you guys for all your help

Jul
25
2 years ago
Activity icon

Replied to How To Convert Html In Blade

just write HTML and save it as filename.blade.php

Activity icon

Started a new conversation How To Pass Checkbox Value 0 If Not Checked And 1 If Checked Using Array.

Here its my HTML form

<form action="{{ url('NewPer') }}" method="post" class="formPermission">
{{ csrf_field() }}

@foreach($perList2 as $li)
    <div class="row">
      <div class="col-sm-4">{{ $li->p_Oname }}</div>
      <div class="col-sm-2"><input type="hidden" name="view[]" value="off"><input name="view[]" type="checkbox" value="on"></div>
      <div class="col-sm-2"><input type="hidden" name="add[]" value="off"><input name="add[]" type="checkbox" value="on"></div>
      <div class="col-sm-2"><input type="hidden" name="update[]" value="off"><input name="update[]" type="checkbox" value="on"></div>
      <div class="col-sm-2"><input type="hidden" name="delete[]" value="off"><input name="delete[]" type="checkbox" value="on"></div>
      
    </div><br>
@endforeach
    <div><input type="submit" class="btn btn-success pull-left" name="submit" value="Save"></div>
</form>

After Post It is taking hidden input if checkbox is checked

array:8 [▼
  "_token" => "2jLsqtIk80XlMyvcO0FrzLW4NqtTQDtywQ9bnoNe"
  "view" => array:6 [▼
    0 => "off"   ------------------->Hidden Input
    1 => "on"
    2 => "off"   ------------------->Hidden Input
    3 => "on"
    4 => "off"   ------------------->Hidden Input
    5 => "on"
  ]
  "add" => array:3 [▶]
  "update" => array:3 [▶]
  "delete" => array:3 [▶]
  "submit" => "Save"
]