RamjithAp

Software Developer at Saggezza Inc.

Experience

24,890

42 Best Reply Awards

  • Member Since 1 Month Ago
  • 1 Lesson Completed
  • 0 Favorites

21st November, 2017

RamjithAp left a reply on Cannot See Files In Laravel On Shared Hosting • 18 hours ago

Change this line

$file = $request->file('file')->store(public_path() . '/uploads/avatars');

RamjithAp left a reply on Cannot See Files In Laravel On Shared Hosting • 18 hours ago

Basically, the images which you wanted to show on your website should be stored after your domain name like yourdomain.com/images/avatars/11.jpg. So when you saving avatar save it into public folder because your domain name is pointed at your public_html/APP so you must save into that directory.

Or show me your file saving codes will help you.

RamjithAp left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 18 hours ago

If it is resolved, accept any of the replies which actually fixed your issue.

RamjithAp left a reply on Cannot See Files In Laravel On Shared Hosting • 18 hours ago

You must save your avatar files in public accessible folder like

~/domains/DOMAIN/public_html/APP/uploads/avatars

RamjithAp left a reply on Email Not Working In Using Smtp.google.com • 19 hours ago

This should work

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls

//do php artisan config:cache

Make sure have enabled access for less secure apps in your google account here https://myaccount.google.com/u/1/lesssecureapps?pli=1&pageId=none

RamjithAp left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 19 hours ago

See my updated answer above.

RamjithAp left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 20 hours ago

Issue is here

  public function index($cid)
    {
       $category =  Category::find($cid);
       $subcategories= SubCategory::where('cid',$cid)->get();
       return view('search-categories')->withCategory($category)->withSubcategory($subcategories);
    }

Change to

  public function index($cid)
    {
       $category =  Category::find($cid);
       $subcategories= SubCategory::where('cid',$cid)->get();
       return view('search-categories')->withCategories($category)->withSubcategory($subcategories);
    }

And now in your views

 @foreach($subcategories as $subcategory)
            <h1 class="f22 gr">{{ $subcategory->csname}}</h1>
 @endforeach

RamjithAp left a reply on How To Show Count Of Array In Blade And If Count Equal To 1 Then Show The Value? • 20 hours ago

Simple, in your controller do

$id_branch = Input::get('id_branch')
$noOfBranch =  count($id_branch);
if($noOfBranch==1){
  $branches = $id_branch[0]; // prints ABC Company
} else {
  $branches = $noOfBranch.' selected'; //prints 2 selected
}

retrun view('your.view',compact($branches));

RamjithAp left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 22 hours ago

Okay, so I have reviewed your code & following things need to be corrected.

  1. Line number 101, wrong variable definition change like below
 @foreach($subcategories as SubCategory)
            <h1 class="f22 gr">{{ $subcategory->csname}}</h1>
 @endforeach

To

 @foreach($subcategories as $subcategory)
            <h1 class="f22 gr">{{ $subcategory->csname}}</h1>
 @endforeach
  1. line number 109, there is some extra character remove it
Route::get('search-categories/{cid}', '[email protected]');
  1. Line number 43, you have not passing the $cid parameter.
 public function index($cid)
    {
       $category =  Category::find($cid);
       $subcategories= Category::find($cid)->subcategories;
       return view('search-categories')->withCategory($category)->withSubcategory($subcategories);
    }
  1. Last but not least you must set column 'cid' as foreign key in order to use laravel relationships. So you have two options now, one is set cid as FK or use direct DB class to get subcategories.

First option, make cid as Fk like this

ALTER TABLE categories_sub
ADD CONSTRAINT FK_cid
FOREIGN KEY (cid) REFERENCES categories(cid);

Second option, If you cant set foreign key go to your SubCatController.php change code like below.

    public function index($cid)
    {
       $category =  Category::find($cid);
       $subcategories= SubCategory::where('cid',$cid)->get();
       return view('search-categories')->withCategory($category)->withSubcategory($subcategories);
    }

All the best! let me know if you still facing any issues.

RamjithAp left a reply on Will Using Subdomain Parameters Cost More In Hosting? • 22 hours ago

No, it will not! No matter you have single domain hosting or multi-domain hosting all you have to do is create wildcard subdomain entry in your server DNS configuration like below.

*.yourdomain.com  - A record - 127.0.0.1 (Your maindomain IP address)

Now you can start using your laravel app with the dynamic subdomains.

20th November, 2017

RamjithAp left a reply on Grouping Routes Not Working As Expected • 1 day ago

Try this


//ROLE 1
Route::group(['middleware' => 'role:role1'], function () {

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

});

//ROLE 2
Route::group(['middleware' => 'role:role2'], function () {

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

});

RamjithAp left a reply on After Refresh Go Back • 1 day ago

Welcome!

RamjithAp left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 1 day ago

Wait, show me your route, controller, modal, view file codes I will tell whats wrong with your code. Problem is you are npt pasting your codes so its difficult to figure out your mistake.

RamjithAp left a reply on After Refresh Go Back • 1 day ago

Controller

<?php 
 public function searchSecurityCode($id)
     {
       $id=Hashids::decode($id);
       $id = implode(',', $id);

       $security_code = Session::get('security_code');

       $this->validate(request(), [
           'q' => 'required'],
           [
               'q.required'    => 'Please type the security code ',

           ]);
            $q = Input::get ( 'q' );

            $success = Clients::where(function($query) use ($id,$q) {
                                          $query->where('id', 'LIKE', $id)
                                                  ->where('security_code', 'LIKE', $q);

                                      })->get();


            if(count($success) > 0) {
              Session::forget('security_code');
              Session::forget('name');
              $products = Products::with('user’,’clients’)->where(‘client_id','LIKE',$id)->paginate(10);
              $resetsecuritycode = Clients::find($id);
              $resetsecuritycode->security_code = str_random(10);
              $resetsecuritycode->save();
              Session::put('products',$products);
              return redirect('products/'.$id.'/history');

             }else {
            return redirect()->back()->with('status', 'No record founded!');
            }

     }

     public function viewhistory($id)
     {
        $products = Session::get('products');
        return view('products.view', compact($products));
     }

Your view file resources/views/products.view.blade.php

@foreach($products as $product)
<h1>{{ $product->name }}
@endforeach

RamjithAp left a reply on How To Give Conditions For User Id != Null • 1 day ago

Then just switch to

$post = new Post;

if(Auth::guard('admin')->check()){
    $post->admin_id = Auth::id();   
} else {
    $post->user_id = Auth::id();
}

//add more stuff if you have
$post->save();

RamjithAp left a reply on Remove Public Folder In Laravel 5.5 • 1 day ago

You just need to cut index.php and .htaccess from public directory and paste it in the root directory,that's all and replace two lines in index.php as

require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

RamjithAp left a reply on Laravel Excel Export Problem • 1 day ago

Just directly export from your controller using DB class

class ExportController extends Controller { 
public function index($type) {

$data = TestModel::get(['title', 'content'])->toArray(); 
return Excel::create('Post Record', function ($excel) use ($data) { 
$excel->sheet('mySheet', function ($sheet) use ($data) { $sheet->fromArray($data); }); })->download($type); } 
}

$data2 = DB::table('your_second_table_name')->get(['title', 'content'])->toArray(); 
return Excel::create('Post Record', function ($excel) use ($data2) { 
$excel->sheet('mySheet', function ($sheet) use ($data2) { $sheet->fromArray($data2); }); })->download($type); } 
}

RamjithAp left a reply on Twitter Icon On The Footer Not Turning Into Color When Mouse Over. • 1 day ago

This is what i have been saying :P

RamjithAp left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 1 day ago

No man! if you sending category & subcategory to view like the way I suggested above then use.

@foreach($subcategories as subcategory)

RamjithAp left a reply on How To Show All Name And Countries Based On Their ID From 2 Different Tables? • 1 day ago

Try this


{{ $test->countries[0]['name'] }}

OR

{{ $test->countries['name'] }}

Also make sure you have column name in your countries table.

RamjithAp left a reply on Twitter Icon On The Footer Not Turning Into Color When Mouse Over. • 1 day ago

Weird! Might be caching.

RamjithAp left a reply on Twitter Icon On The Footer Not Turning Into Color When Mouse Over. • 1 day ago

I'm using google chrome.

RamjithAp left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 1 day ago

I guess you are trying this way

@foreach($category->subcategories as subcategory)

Instead of this (if you using my above samples)

@foreach($subcategories as subcategory)

RamjithAp left a reply on Undefined Variable: Template (View:... • 1 day ago

Make sure your notification_templates table has some data in it. Otherwise in your view

@if($template)
 @foreach($template as $taken)
    {{ $taken->title }}                         
 @endforeach 
@endif

RamjithAp left a reply on How To Implement A Live Chat? • 1 day ago

Suggest tawk.to they are the best & beast in free chat network.

RamjithAp left a reply on Automatic Ajax Request • 1 day ago

@david001 You are missing single quotes around 'username' parameter. Try this

<script>
(function () {
        var username = "john";
        $.ajax({
            type:"GET",
            cache:false,
            url:"{{ url('/') }}/getValue",  
            data:{'username':username},
            success: function(data) {
                console.log('posted');
          }
        });
});
</script>

RamjithAp left a reply on How To Give Conditions For User Id != Null • 1 day ago

In your controller

//For admin posts
$posts = Post::whereNotNull('admin_id');

//For users post
$posts = Post::whereNotNull('user_id');

RamjithAp left a reply on User Registration In Laravel • 1 day ago

In your RegisterController.php remove password from validator array

  protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:ws_users'
        ]);
    }

RamjithAp left a reply on How To Show All Name And Countries Based On Their ID From 2 Different Tables? • 1 day ago

There is discrepancy in the variable name in your question and above answers. Follow this your modal

App/User.php
 public function countries(){
 return $this->hasMany(App\Countries,'id', 'countries_id');
       }
App/Countries.php
public function user(){
    return $this->belongsTo(App\User, 'countries_id');
    }

Controller

$users = User::all();
return view('some', compact('users));

View

@foreach($users as $user)
    <li>{{ $user->name}} - {{ $user->countries->name }}</li>
@endforeach

RamjithAp started a new conversation Twitter Icon On The Footer Not Turning Into Color When Mouse Over. • 1 day ago

Good morning all ;)

RamjithAp left a reply on Authentication Based On User Type • 1 day ago

Laravel has its own core logic for managing permissions. It was introduced in version 5.1.11 and has remained almost unchanged since. There we have things like:

-Gates and Policies
-$this->authorize() method
[email protected] and @cannot Blade commands

17th November, 2017

RamjithAp left a reply on Order By Own Key • 4 days ago

Try this

$units= Units::with('users')->get()->sortBy(function($unit)
{
    return $unit->users->count();
});

For more details refer this thread https://stackoverflow.com/questions/24208502/laravel-orderby-relationship-count/24208979#24208979

RamjithAp left a reply on How To Send Email With Laravel Commands • 4 days ago

Try this

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls

RamjithAp left a reply on How To Send Email With Laravel Commands • 4 days ago

First create command like this

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;

class SendEmail extends Command
{
    protected $signature = 'emails:send';

    protected $description = 'Sending emails to the users.';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        $data = array(
            'name' => "xxx'
       );

        Mail::send('emails.test', $data, function ($message) {

            $message->from('[email protected]');

            $message->to('[email protected]')->subject('xxx');

        });
        $this->info('The emails are send successfully!');
    }
}

And then register it in Kernel like this

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    protected $commands = [
        Commands\Inspire::class,
        Commands\SendEmail::class,
    ];

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('emails:send')->daily();
    }
}

Finally hit this command

php artisan emails:send

RamjithAp left a reply on Display Sub Categories On Seperate Page When Clicked On Category Link In Home Page • 4 days ago

Go to your App/Categories.php model and write

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Categories extends Model
{
    /**
     * Get the comments for the blog post.
     */
    public function subcategories()
    {
        return $this->hasMany('App\SubCategories','foreign_key_column_name');
    }
}

Also in App/SubCategories.php model

public function categories()
{
    return $this->belongsTo('App\Categories','id');
}

Then in your controller

$category =  Category::find($id);
$subcategories= Category::find($id)->subcategories;

return view('index')->withCategory($category)->withSubcategories($subcategories); 

And In your view

@foreach($subcategories as subcategory)
     <span>{{ $subcategory->name}}</span>
@endforeach

For more details read https://laravel.com/docs/5.5/eloquent-relationships#one-to-many

RamjithAp left a reply on Swift_TransportException In AbstractSmtpTransport.php Line 383: Expected Response Code 250 But Got Code "530", With Message "530 5.7.1 Authentication Required " • 4 days ago

This should work

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls

//do php artisan config:cache

Make sure have enabled access for less secure apps in your google account here https://myaccount.google.com/u/1/lesssecureapps?pli=1&pageId=none

RamjithAp left a reply on Error 404 But Route Is In The Route:list • 4 days ago

Always define your static routes first, the dynamic routes. Like below

//web.php
Route::get   ('employer/jobs/{job}/edit', '[email protected]')->name('employer.jobs.edit');
Route::get   ('employer/jobs/{job}', '[email protected]')->name('employer.jobs.show');
Route::post  ('employer/jobs', '[email protected]')->name('employer.jobs.store');
Route::get   ('employer/jobs','[email protected]')->name('employer.jobs.index');
Route::get   ('employer/jobs/create','[email protected]')->name('employer.jobs.create');
Route::delete('employer/jobs/{job}', '[email protected]')->name('employer.jobs.destroy');


Route::match(array('PUT', 'PATCH'), "/employer/jobs/{job}", array(
      'uses' => '[email protected]',
      'as' => 'employer.jobs.update'
));

RamjithAp left a reply on Swift_TransportException Connection To Tcp://mail.xxxx.com:465 Timed Out • 4 days ago

First change your mail_driver to mailgun and try if not work. Then go to your env file add this details.

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
[email protected] //get this from mailgun dashboard
MAIL_PASSWORD=8aXXX029XXXXXXXXXX4fXXXX4bd //get this from mailgun dashboard
MAIL_ENCRYPTION=tls
MAILGUN_DOMAIN=yourdomain.com 
MAILGUN_SECRET=key-4d3XXXXXXXXXXXXXX4XXX7843 //get this from mailgun dashboard

Make sure your domain name in mailgun account dashboard is in active status.

RamjithAp left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 4 days ago

Go to your App/Categories.php model and write

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Categories extends Model
{
    /**
     * Get the comments for the blog post.
     */
    public function subcategories()
    {
        return $this->hasMany('App\SubCategories','foreign_key_column_name');
    }
}

Also in SubCategories.php

public function categories()
{
    return $this->belongsTo('App\Categories','id');
}

Then in your controller simple

$category =  Category::find($id);
$subcategories= Category::find($id)->subcategories;

return view('index')->withCategory($category)->withSubcategories($subcategories); 

And In your view

@foreach($subcategories as subcategory)
     <span>{{ $subcategory->name}}</span>
@endforeach

For more details read https://laravel.com/docs/5.5/eloquent-relationships#one-to-many

RamjithAp left a reply on Swift_TransportException Connection To Tcp://mail.xxxx.com:465 Timed Out • 4 days ago

Show your mail.php config (Except email password) so we can help you.

16th November, 2017

RamjithAp left a reply on Please I Am Getting This Error [BadMethodCallException] • 5 days ago

Show me your route file for /keysearch.

RamjithAp left a reply on PDO Drivers "missing" - WampServer 2.5 - Windows 8.1 • 5 days ago

Click on wamp icon on right bottom of your screen-> navigate to PHP - > then PHP Extensions -> then select php_pdo_mysql & php+pdo_sqlite. Then restart all services.

RamjithAp left a reply on Display Sub Categories Under A Particular Category Clicked From Homepage • 5 days ago

Always use URL helper so that your link will not break when you use it common header file.

    <a href="{{ url('category')}}/{{ $category->id }}">{{ $category->name }}</a>

RamjithAp left a reply on Laravel Email Sent Out Twice Sometimes (not Always). • 5 days ago

Check few things check $to_address and $bcc_address not assigned to same value. check your code not running twice on foreach loop etc. Make sure your form submit button cannot be clicked twice use jquery and disable on the first click.

RamjithAp left a reply on Redirect To Another Url Or Website • 5 days ago

Here you go https://laravel.com/docs/5.5/redirects

return redirect('http://anotherdomain.com/');

RamjithAp left a reply on Get JSON Response Instead Of Login Form With Passport • 5 days ago

If you use a browser to access API protected page it will redirect to login route. Try testing your API routes from POSTMAN or Jquery AJAX etc. Also make sure your request to API protected routes should have header like below

Authorization:Bearer {access_token}
Accept:application/json

If you don't have access token refer this https://laravel.com/docs/5.5/passport#password-grant-tokens to get one first.

RamjithAp left a reply on Swift_TransportException In AbstractSmtpTransport.php Line 383: Expected Response Code 250 But Got Code "530", With Message "530 5.7.1 Authentication Required " • 5 days ago

If you are using your Gmail account for SMTP then make sure have enabled access for less secure apps in your google account here https://myaccount.google.com/u/1/lesssecureapps?pli=1&pageId=none

Enable there and then try sending the email.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.