mardi 1 janvier 2019

How can I create two different notifications for laravel? (like orderquote and booking)

I am trying to create two notifications using Laravel. First when the client fills out the orderquote form, the admin user at the backend gets the notification on their dashboard showing a notification of a new quote received, and if the client proceed further towards this booking and confirm it, the admin user again gets the notifications of a new bookings. But I want this booking to show separately. I have New quote icon and i also have new booking icon separate. so I want it show the notifications accordingly. So far, I can only do it one notification. I want something similar to this website if we see on top right corner on the navigation bar. We all have separate notifications for various things. How can I do that?

Code for the Quote Notifications:

App/Http/Controller/newQuoteController.php

$user = user::all();
\Notification::send($user,new NotifyUser($newquote));

then in my App/notifications/NotifyUser.php

public $newquote;

public function __construct(NewQuote $newquote)
{
    $this->newquote=$newquote;
}

public function via($notifiable)
{
    return ['database'];
}

public function toDatabase($notifiable)
{
    return [
       'data' => $this->newquote->id,
    ];
}

Now for the booking:

App/Http/Controller/confirmedBookingController.php

  $user = user::all();
  \Notification::send($user,new BookingNotification($bookings));

then in my App/notifications/BookingNotification.php

public $bookings;

public function __construct(Bookings $bookings)
{
    $this->bookings=$bookings;
}

public function via($notifiable)
{
    return ['database'];
}

public function toDatabase($notifiable)
{
  return [

     'data' => $this->bookings->id,
  ];
}



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2AoPqvI
via IFTTT

What is the data type which i use for images in laravel

I'm currently use binary data type for images. $table->binary('image'); when i try to save image which has more than 64kb size, error is raised #1366 - Incorrect integer value: '' for column 'pet_owner_id' at row 1. in mysql that data type showed as blob



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2BSGgHv
via IFTTT

Facing a issue with Facade.php in migrate

I am using an existing project from GitHub, and I am trying to run Laravel very 1st time, but I am facing

In Connection.php line 664:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S
  QL: alter table `users` add unique `users_email_unique`(`email`))

In Connection.php line 458:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes

later I took some instructions and added use Illuminate\Support\Facades\Schema; under the AppServiceProvider.php but after adding I am getting a different error like

C:\wamp64\www\localseo>php artisan migrate

In Facade.php line 221:

  Call to undefined method Illuminate\Database\Schema\MySqlBuilder::defaultStringLenght()

Please help me how to avoid the error.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Apdfn3
via IFTTT

Can't get value from second join table in whereHas clause

i have to problem, i need to search if user is in specific radius. I have two join tables on users, address and search radius...query will received two param lat and log.

$query = Users::query();
$query->with('location', 'serach_area');
$query->whereHas('location', function ($query) use  ($latitude, $longitude) {
    $query->select('users_locations.latitude as latitude', 'users_locations.longitude as longitude', 'users_locations.user_id', 'search_area.radius s radius')
        ->selectRaw("(6371 * acos(cos(radians('.$latitude.')) * cos(radians(latitude)) * cos(radians(longitude) - radians('.$longitude.'))   sin(radians('.$latitude.')) * sin(radians(latitude)))) as haversine")
        ->having("haversine", "<", "radius");    });

I can't get search area.radius if I hard coded number, it works perfectly if anyone have any idea please commented



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2BWUlnd
via IFTTT

How to autoload service namespace in laravel 5.6

I have created some library services in app\Library. I used AppServiceProvider to bind that service using following code:

$this->app->bind('App\Library\Globalfunction', function ($app) {
    return new Globalfunction();
});

app\Library\Globalfunction.php

<?php
namespace App\Library;

    class Globalfunction {
        protected $_ci;
        public $siteConfig=array();
        public $smtpConfig=array();
        public $socialConfig=array();

        public $paramConfig;
        public $paramFrom;

        public function test($param) {
            return $param;
        }
    }
?>

To use this test() in controller i am including namespace using following:

use App\Library\Globalfunction;

once namespace is included i use following code:

$globalFunction = new Globalfunction();
echo $globalFunction->test('hello');

All of this code working fine but i don't want to add use App\Library\Globalfunction; in each file so is there anyway i can do that? is there any autoload file where i can put this and i can access Globalfunction?

I google solution for that and i tried several solutions like add this in composer or create package etc but it's not working so please if anyone have solution for this problem please let me know.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2VjfUaN
via IFTTT

No simultaneous login for web using laravel

How to restrict same user from simultaneous login in web for same device or different device. For eg. if a user has logged in one system and trying to login with same credentials in another device, he/she must be logged out from the previous device.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2TlYDeZ
via IFTTT

Laravel verification link with session

Everybody, I need to redirect back with message "active link sent successfully "

       <a href="">request another</a>

How I add a session to link if I'm not using any form



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2TjI7Mz
via IFTTT