Laravel join query with conditions

I’m still not completely sure about your table relationships but from my guess, I came up with the following solution, first create the relationships using Eloquent models: User Model (for usres table): namespace App; use App\Course; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; public function courses() { return $this->hasMany(Course::class); … Read more

Google reCaptcha with Laravel

Laravel 8 Google Captcha without any third party package. First add below keys in .env file GOOGLE_CAPTCHA_SITE_KEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI GOOGLE_CAPTCHA_SECRET_KEY=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe GOOGLE_CAPTCHA_VERIFICATION_URL=https://www.google.com/recaptcha/api/siteverify Note:these are test keys from google document. then in config folder create a file called google_captcha.php <?php return [ ‘site_key’ => env(‘GOOGLE_CAPTCHA_SITE_KEY’), ‘secret_key’ => env(‘GOOGLE_CAPTCHA_SECRET_KEY’), ‘gc_verification_url’ => env(‘GOOGLE_CAPTCHA_VERIFICATION_URL’), ‘error_codes’ => [ “missing-input-secret” => “The secret parameter … Read more

Laravel setup failed to open stream

You can simply use (I’ve same setup for all of my projects) in httpd-vhosts.conf file <VirtualHost iproject.dev> DocumentRoot “C:/xampp/htdocs/iProject/public” ServerName iproject.dev </VirtualHost> Also, add the following line in you C:\Windows\System32\drivers\etc\hosts file 127.0.0.2 iproject.dev # 127.0.0.2 could be 127.0.0.3 or …4/…5 For example, this is a part of my hosts file in win-7 127.0.0.1 localhost 127.0.0.1 … Read more

Including a css file in a blade template?

@include directive allows you to include a Blade view from within another view, like this : @include(‘another.view’) Include CSS or JS from master layout asset() The asset function generates a URL for an asset using the current scheme of the request (HTTP or HTTPS): <link href=”{{ asset(‘css/styles.css’) }}” rel=”stylesheet”> <script type=”text/javascript” src=”{{ asset(‘js/scripts.js’) }}”></script> mix() … Read more

How to add jQuery in Laravel project

you can use online library <link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css”> <link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css”> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script> <script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js”></script> or else download library and add css in css folder and jquery in js folder.both folder you keep in laravel public folder then you can link like below <link rel=”stylesheet” href=”https://stackoverflow.com/questions/32498328/{{asset(“css/bootstrap-theme.min.css’)}}”> <script src=”https://stackoverflow.com/questions/32498328/{{asset(“js/jquery.min.js’)}}”></script> or else {{ HTML::style(‘css/style.css’) }} {{ HTML::script(‘js/functions.js’) … Read more