Category

Laravel

Category

Laravel 8 CRUD using ajax Step 1: Install the laravel project using the command line. composer create-project –prefer-dist laravel/laravel laravel8ajax Step 2: Open project in code and use vs code terminal. cd laravel8ajax code . Step 3: find .env file in root directory than setup database configuration. DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=database_name DB_USERNAME=database_username DB_PASSWORD=database_password Step 4: run Migration command php artisan make:migration create_books_table Now go to app/datatabase/migrations and open books migration file and put code within…

How to send mail in Laravel 8 Step 1: Create a Laravel 7 project Step 2: Open laravel project set .env configuration MAIL_DRIVER=smtp MAIL_HOST=smtp.googlemail.com MAIL_PORT=465 [email protected] MAIL_PASSWORD=gmail_password MAIL_ENCRYPTION=ssl Step 2: Add Route with routes/web.php Route::get(‘send-mail’,’MailSend@mailsend’); Stage 3: Create Mail In this progression, we will make mail class SendMail for email sending. Here we will compose code for which view will call and the question of the client. So we should run cry direction. you can…

Step 1: Install Composer in your system Step 2: Download laravel using composer package composer create-project –prefer-dist laravel/laravel laravel8imageupload Step 3: Configure your database in .env file DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=multipleImage DB_USERNAME=root DB_PASSWORD=root@123 Step:4 Now, run command for creating model and migration php artisan make:model file -m Update your migration field for inserting image path public function up() { Schema::create(‘files’, function (Blueprint $table) { $table->id(); $table->string(‘filenames’); $table->timestamps(); }); } Now, run migrate command. php artisan…

Laravel 8 CRUD Step 1: Install Laravel 8 first of all, we need to get fresh Laravel 8 version application using bellow command, So open your terminal OR command prompt and run bellow command: git clone -b develop https://github.com/laravel/laravel.git Step 2: Database Configuration Open laravel and set hostname, username, password and database name in .env file DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_blog DB_USERNAME=root DB_PASSWORD=root Step 3: Create Migration Now we are going to create a blog. so…

By default, Eloquent converts created_at and updated_at columns to instances of Carbon. So if you are fetching the data using Eloquent, then you can do it as below. $object->updated_at->diffForHumans(); If you want to customize the fields that will be mutated automatically, then within your model, you can customize them as you wish. // Carbon instance fields protected $dates = [’created_at’, ‘updated_at’, ‘deleted_at’];

<form class=”newsletter” id=”newsletter”> @csrf <input type=”email” placeholder=”Enter your email address” name=”email” required=””> <button type=”submit”>Subscribe</button> </form> <script> $(‘.newsletter’).on(‘submit’, function(e) { e.preventDefault(); $.ajax({ type: “POST”, url: ‘newsletter’, data: $(this).serialize(), success: function(msg) { document.getElementById(“newsletter”).reset(); swal(“thank you for subscribing newsletter!”); } }); }); </script>

Return from controller return Redirect::back()->withErrors($validator)->withInput(); View part <input type=”text” class=”form-control” name=”name” value=”{{ old(‘name’) }}”> @if($errors->has(‘name’)) <p class=”alert alert-danger print-error-msg”><span class=”glyphicon glyphicon-exclamation-sign” aria-hidden=”true”></span> {{ $errors->first(‘name’) }} </p> @endif

How to show selected value from database in dropdown using Laravel? <select name=”state” id=”state” class=”form-control form_cont” required> <option selected=”true” disabled=”disabled”>Select State</option> @foreach($city as $cities) <option value=”{{ $cities->cityState }}” {{$customerData->state == $cities->cityState ? ‘selected’ : ”}}>{{ $cities->cityState }}</option> @endforeach </select>

Alert::success(‘Success Title’, ‘Success Message’); Alert::info(‘Info Title’, ‘Info Message’); Alert::warning(‘Warning Title’, ‘Warning Message’); Alert::error(‘Error Title’, ‘Error Message’); // Using the helper alert()->success(‘Title’,’Lorem Lorem Lorem’); alert()->info(‘Title’,’Lorem Lorem Lorem’); alert()->warning(‘Title’,’Lorem Lorem Lorem’); alert()->error(‘Title’,’Lorem Lorem Lorem’);