BalaMurugan08

BalaMurugan08

Member Since 1 Month Ago

Experience Points
1,080
Total
Experience

3,920 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
1
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
1,080 XP
Oct
29
4 weeks ago
Activity icon

Replied to Sum Column And Display In Blade

I'm the one need to be sorry, your first code is working fine, because of overthinking my brain stop working.

my blade

 <h5>{{$total_redeemed}} Vouchers Redeemed</h5> 

just erase the for each working well thank you so much for your help

Activity icon

Replied to Sum Column And Display In Blade

Thank you for Your reply, the sum is working but its looping.

Activity icon

Started a new Conversation Sum Column And Display In Blade

How to sum data from column where the user id is, i have created a query to display data and i want data from column is_redeemed that are summed.

my query in controller

$data = DB::table('voucherdetails')
->join('addvouchers','voucherdetails.id','=','addvouchers.voucher_id')
->select('voucherdetails.description','addvouchers.voucherCode','addvouchers.voucherTitle','addvouchers.quantity','addvouchers.expired','addvouchers.expiredDate','addvouchers.id','addvouchers.voucher_id','addvouchers.is_redeemed')
->where(['voucherdetails.user_id' => $userid ])
->get(); 

return view('/vendor/vendorpanel',['data' => $data],['test' => $test]);

my blade


 <p class="card-text">
       @foreach ($data as $redeemed)
           <h5>{{$redeemed->sum('is_redeemed')}} Vouchers Redeemed</h5> 
        @endforeach
</p>

And I got This error Call to undefined method stdClass::sum()

Can anyone explain how should this be done,and why I'm getting this error.

Oct
20
1 month ago
Activity icon

Replied to Middleware Check User Package And Count Post To Redirect.

Thank you so much for the explanation, now i understand my mistake.

Activity icon

Started a new Conversation Middleware Check User Package And Count Post To Redirect.

Hi I have did a Middleware to check the user package and wants to limit the add voucher by the user, so for example the user package is Basic Package so they can only add 3 vouchers.

For count the added voucher, i already have a column in users table as addvoucher_count.

For the user package, i have created a column in users table as vendorType.

So if the middleware check the user has package and addvouchers already reach limit based on packages it should redirect to home page with a message. My problem is the page doesn't redirect.

My Middleware

	public function handle($request, Closure $next)
    {
        $userid = Auth::user()->id;
        $vendortype = DB::table('users')->select('vendorType')->where('id' ,$userid);
        $vouchercount = DB::table('users')->select('addvoucher_count')->where('id' ,$userid);

         if ($vendortype == 'advancePackage') {
            if ($vouchercount == 10) {
                 return redirect('/')->with('message', trans('Upgrade To Premium Package To Add More Vouchers'));
            }
           
        }elseif ($vendortype == 'basicPackage') {
            if ($vouchercount == 3) {
                 return redirect('/')->with('message', trans('Upgrade To Advance Package To Add More Vouchers'));
            }
        }

        return $next($request);
    
    }

My routes

Route::get('/voucherdetails', '[email protected]')->middleware('checkpost');

If the there is a mistake or any other problem please let me know and advise some solution it will be much appreciate,Thank you.

Oct
19
1 month ago
Activity icon

Replied to How To Count Post Of User?

I got this error sir,

Error Call to a member function increment() on null

Activity icon

Replied to How To Count Post Of User?

instead using user I use companyreg table, how to get count in voucherdetails controller

my companyregister model

    protected $table = 'companyregisters';
    protected $fillable = [
        'companyName', 'companyregNo','file','category','addvoucher_count'
    ];

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

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

voucherdetails model

    protected $table = 'voucherdetails';
    protected $fillable = ['title', 'description','company_id']; 



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

        public function addvoucher()
    {
         return $this->hasOne('App\addvoucher', 'voucher_id' , 'id');
    }

my voucherdetails controller

 public function store(Request $request){
	    
	    $voucherdetail = new voucherdetails();

        $voucherdetail->title = $request->input('title');
        $voucherdetail->description = $request->input('description');
        $voucherdetail->user_id = Auth::user()->id;

        $id = Auth::user()->id;#Authenticate User's ID
        $user      = User::find($id);#Find user that login using authenticate user ID
        $company   = $user->companyregisters;#find users company register row in companyregister table
        $companyId = $company->id;#Get companyregister ID that Belongs to user that login 

        $voucherdetail->company_id = $companyId;

        
        $voucherdetail->save();
        
        return redirect()->to('addvoucher');
	    	
	    }
Activity icon

Replied to How To Count Post Of User?

I understand this sir, but I don't no how to implement this to addvoucher_count column, every time user submit the voucher details the count should be added in users addvoucher_count column table.

Oct
18
1 month ago
Activity icon

Started a new Conversation How To Count Post Of User?

I'm trying to learn about the count method but not understand much, I have 2 table users and voucherdetails I want to count voucherdetails that add by user. So in the users table have addvoucher_count column. So every add voucherdetails by user should be count. How to implement that?

Oct
15
1 month ago
Activity icon

Replied to How To Set User Can Only Redeem Voucher ONE TIME.

oh exixsts I understand now ,this solved my problem thank you @silencebringer

Oct
14
1 month ago
Activity icon

Started a new Conversation How To Set User Can Only Redeem Voucher ONE TIME.

I have 3 table, Users, vouchers and users_voucher, so if the user redeem the voucher the voucher quantity will decrease in vouchers table and also will add userID and voucherID in users_voucher table, for the voucher decrement part and adding userid, voucherID in users_table is working fine, but i want to check if the user that login already redeemed the voucher or not, if the user already redeem redirect to same page with error. My problem is user can keep on redeem. I'm not too familiar with laravel, I'm learning for now, so if there is any mistake please point out and give me some solution and advice how to make it.

My controller

	$idVoucher = $request->input('voucherid');

        $userid = Auth::user()->id;
      
        $redeemer =  DB::table('users_voucher')->select('voucher_id')->where('user_id', $userid);

         if ($redeemer == $idVoucher)  {
         
         return redirect('/')->with('message', trans('Already Redeem This Voucher'));
       
          }else{
           DB::table('voucher')->where('id', $idVoucher)->decrement('quantity', 1);
          
                  $uservoucher = new usersvoucher();
          
                  $uservoucher->voucher_id = $request->input('voucherid');
                  $uservoucher->user_id = Auth::user()->id;
                  $uservoucher->save();
         }
Oct
12
1 month ago
Activity icon

Started a new Conversation How To Hide Text, If The Date Value In Table Is After Today's Date?

I want to hide a text if value of date in table is today's and after todays date's, for now I can get todays date using carbon method, so I can hide the text if the date value is todays date. I want to hide after today's date also

my controller

function test_query(Request $request){

 $data = DB::table('companyregisters')

 		->join('voucherdetails','companyregisters.id','=','voucherdetails.company_id')
 		->join('addvouchers','voucherdetails.id','=','addvouchers.voucher_id')
 		->select('voucherdetails.description','companyregisters.companyName','addvouchers.voucherCode', 'addvouchers.voucherTitle' , 'companyregisters.file', 'addvouchers.quantity','addvouchers.id','addvouchers.expired','addvouchers.expiredDate')
        ->where(['companyregisters.category' => 'Fashion'])
 		->get();

        $date = Carbon::now();
        $todaysDate =  $date->toDateString();  

 return view('voucherCategory/fashion',['data' => $data],['todaysDate ' => $todaysDate ]);  }

my blade.php

@if($row->expiredDate == $todaysDate )
	Hello World(test)
@else
	Test 
@endif

my table

$addvoucher->voucherTitle = $request->input('voucherTitle');
    $addvoucher->voucherCode = $request->input('voucherCode');
    $addvoucher->user_id = Auth::user()->id;
    $addvoucher->quantity = $request->input('quantity');
    $addvoucher->expiredDate = $request->input('datepicker');
Oct
11
1 month ago
Activity icon

Replied to How To Disable Button Based On Value In Table?

Thank you so much for the explanation!!

Activity icon

Replied to How To Disable Button Based On Value In Table?

Thank you sir, problem solved can I know y using first instead of get?? Can I get some explanation

Activity icon

Started a new Conversation How To Disable Button Based On Value In Table?

I have table addvoucher and got a column expired, so if the value in expired ''1'' redeem button should disable in fashion.blade.php

my fashionController

 $id = $request->input('voucherid');

     $expired = DB::table('addvouchers')->select('addvouchers.expired')->where('id', $id)->get();

    	return view('voucherCategory/fashion',['expired' => $expired]);

my fashion.blade.php

@if($expired == '1')
      <button type="submit"  class="btn btn-primary"   disabled='disabled'  > Expired </button>
      @else
      <button type="submit"  class="btn btn-primary" data-confirm='Are You Sure Reedem?'> Reedem Now </button>

      @endif
Oct
09
1 month ago
Activity icon

Started a new Conversation How To Get Value In Table And Update Has Expired In A Column Of Same Table

I have made a Voucher web, so when user redeem the voucher, the quantity of voucher will decrease, so when the voucher quantity has ''0'' value the voucher must declare has expired, so what should I do. I just need some suggestion of this, thank you in advance!!

Oct
07
1 month ago
Activity icon

Replied to How To Get Id Of Newly Created User And Pass It To A Controller

nope, i can submit but the user_id is null

Activity icon

Started a new Conversation How To Get Id Of Newly Created User And Pass It To A Controller

How to get the id off new register user?? I need to pass the id to table roles

my register controller

public function store(Request $request)

{	
	$vendorReg = new User();

    $vendorReg->name = $request->input('name');
    $vendorReg->email = $request->input('email');
    $vendorReg->password = $request->input('password');

    $role = role::select('id')->where('name', 'vendor')->first();

    
    $id = $vendorReg->id;
	$vendorReg->roles()->attach($role);
	$vendorReg->roles()->attach()->user_id($id); //here the user id null

    $administrators = User::whereHas('roles', function($q){
        $q->where('name', 'Admin');
    })->get();

    

    foreach ($administrators as $administrator) {
        $administrator->notify(new AdminNewUserNotification($vendorReg));
        # code...
    }

    return $vendorReg;
}
Oct
06
1 month ago
Activity icon

Replied to How To Get Image From Storage Folder And Display

Thank You So Much Sir,

I run php artisan storage::link

and I change this

src="storage/upload/{{ $row->file }}"

Activity icon

Started a new Conversation How To Get Image From Storage Folder And Display

I want to display photos from storage folder but the photo is not shown, I have companyregister table, I want to display all my company name with the image they uploaded. I'm new to laravel, I would like to have solution and explanation for this problem.

my travelController

->join('voucherdetails','companyregisters.id','=','voucherdetails.company_id')
 		->join('addvouchers','voucherdetails.id','=','addvouchers.voucher_id')
 		->select('voucherdetails.description','companyregisters.companyName','addvouchers.voucherCode', 'addvouchers.voucherTitle', 'companyregisters.file')
        ->where(['companyregisters.category' => 'Travel'])
 		->get();

my travel.blade.php

<tbody>
			
			@foreach($data as $row)
				<tr>
					<td>{{$row->companyName}}</td>

					<td><img src="storage/app/public/upload/{{ $row->file }}" class="img img-thumbnail"></td>

					<td>{{$row->voucherTitle}}</td>

					<td>{{$row->description}}</td>

					<td>{{$row->voucherCode}}</td>

				</tr>


			@endforeach
		</tbody>

No errors but not displaying did I miss anything or the code is wrong??

Oct
05
1 month ago
Activity icon

Replied to How To Get Data From Relationship Table

mine is user hasOne companyregister, companyregister belongsTo user

companyregister hasMany voucherdetails, voucherdetails belongsTo company register

and the last one is voucherdetails hasOne addvoucher, addvoucher belongsTo vocherdetails

Activity icon

Replied to How To Get Data From Relationship Table

I can get the company id , now i can submit voucherdetails, after that when user addvoucher voucherdetails id need to submit in addvoucher table , I tried the same method but cant its say error "Property [id] does not exist on this collection instance." can u please explain why this happen and what was the solution for this

Activity icon

Replied to How To Get Data From Relationship Table

I tried this and got error sir

    $loggedInUserCompany=Auth::User()->voucherdetails;
    $voucherID = $loggedInUserCompany->id;
    $addvoucher->voucher_id = $voucherID;

I got this error "Property [id] does not exist on this collection instance."

Activity icon

Replied to How To Get Data From Relationship Table

Sir I have solved, with change only these code

$id = Auth::user()->id;
    $user      = User::find($id);
    $company   = $user->companyregisters;
    $companyId = $company->id;

    $voucherdetail->company_id = $companyId;

Thank you so much sir.

Activity icon

Awarded Best Reply on How To Check Exist Data In Relationship Table And Redirect If Data Exist

I was tried different way its working now but not sure it was clean code or not

if ( Auth::User() -> hasuserID (Auth::id())){

                   	 return  'voucherdetails';

                        
              }else
                  {
                         return 'home';  
 		      }

And in model

public function hasuserID($userid) { if($this->companyregisters()->where('user_id', $userid)->first()){ return true; } return false; }

Its Working, I will try your method to

Oct
04
1 month ago
Activity icon

Replied to How To Get Data From Relationship Table

my companyregister

    Schema::create('companyregisters', function (Blueprint $table) {
        $table->increments('id');
        $table->unsignedInteger('user_id');
        $table->string('companyName');
        $table->string('companyregNo');
        $table->string('file');
        $table->timestamps();
    });

my voucherdetails

    Schema::create('voucherdetails', function (Blueprint $table) {
        $table->increments('id');
        $table->unsignedInteger('user_id');
        $table->unsignedInteger('company_id');
        $table->string('title');
        $table->string('description');
        $table->timestamps();
    });

my user

    Schema::create('users', function (Blueprint $table) {
        $table->id();
        $table->string('name');
        $table->string('email')->unique();
        $table->timestamp('email_verified_at');
        $table->string('provider')->nullable();
        $table->string('provider_id')->nullable();
        $table->boolean('approved')->default(0)->nullable();
        $table->string('password')->nullable();
        $table->rememberToken();
        $table->timestamps();
    });
Oct
02
1 month ago
Activity icon

Started a new Conversation How To Get Data From Relationship Table

I have created 4 separated table

users table
companyregister table
voucherdetails table
addvoucher table

so when the user login to voucher details I need to get the companyregister id to submit. I have tried some method but still cant understand how it works.

my voucherdetails controller

$voucherdetail = new voucherdetails();

    $voucherdetail->title = $request->input('title');
    $voucherdetail->description = $request->input('description');
    $voucherdetail->user_id = Auth::user()->id;
    $companyid = Auth::User('id')->companyregisters()->id;
    $voucherdetail->company_id = $companyid;
    $voucherdetail->save();

my voucherdetails model

    public function companyregisters(){
	 return $this->belongsTo('companyregisters');
	 }

my companyregisters model

    public function voucherdetails()
{
     return $this->hasMany('voucherdetails');
}

So anyone know the solution, please elaborate the solution I want to understand it, thank you in advance!!

Activity icon

Started a new Conversation Laravel Join Multiple Table Return Duplicate Data

I trying to display data from 3 multiple table, this query is working but its display duplicate data how to prevent it,

I tried Laravel ->distinct() method, and also some other method but its not working.

my query

$data = DB::table('users')

    ->join('companyregisters','users.id','=','companyregisters.user_id')

    ->join('voucherdetails','users.id','=','voucherdetails.user_id')

    ->join('addvouchers','users.id','=','addvouchers.user_id')

    ->select('voucherdetails.description','companyregisters.companyName','addvouchers.voucherCode', 			 
       'addvouchers.voucherTitle')

    ->get();
Activity icon

Replied to How To Check Exist Data In Relationship Table And Redirect If Data Exist

I was tried different way its working now but not sure it was clean code or not

if ( Auth::User() -> hasuserID (Auth::id())){

                   	 return  'voucherdetails';

                        
              }else
                  {
                         return 'home';  
 		      }

And in model

public function hasuserID($userid) { if($this->companyregisters()->where('user_id', $userid)->first()){ return true; } return false; }

Its Working, I will try your method to

Oct
01
1 month ago
Activity icon

Started a new Conversation How To Check Exist Data In Relationship Table And Redirect If Data Exist

I have created a login with two roles admin & user and user registration with authentication, so when user login the page have to redirect to a page call "home" if the user already registered at "home" the user should redirect to "addvoucher" page.("home" is a page for register company details) so here I want is to check if the user that login already register for the company details or not, if registered the user have to redirect to "addvoucher" page, if not registered means the user must stay at the home page after login.

I'm new for php laravel hope anyone can consider and help, Thank you in advance!!