A Web Framework (WF) or Web Application Framework (WAF) which helps to build Web Applications. Web frameworks provide tools and libraries to simplify common web development operations. This can include web services, APIs, and other resources. Web frameworks help with a variety of tasks, from templating and database access to session management and code reuse. More than 80% of all web app frameworks rely on the Model View Controller architecture.
Create a Mailable class first you have to create an account in mailtrap or click this url https://mailtrap.io/ after create account you have to copy Username: XXXXXXXXX and password: XXXXXXXXXX and put in .env file see pic
Now we are ready for make mailable class for this we have to go teminal and write following
Next step make one blade page resources/view/dynamic_email_template.blade.php
<p style="margin-left:10%;">First Name - <b>{{ $data['name'] }} </b></p> <p style="margin-left:10%;">last Name - <b>{{ $data['email'] }} </b></p>
<p>It would be appriciative, if you gone through this feedback.</p>
Next one to create SendMail.php file run below code.
php artisan make:mail SendMail
Next step go to App\Mail\SendMail.php and paste below code
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue;
class SendMail extends Mailable { use Queueable, SerializesModels; public $imagesendbymailwithstore; /** * Create a new message instance. * * @return void */ public function __construct($imagesendbymailwithstore) { $this->imagesendbymailwithstore = $imagesendbymailwithstore; }
/** * Build the message. * * @return $this */ public function build() { return $this->from('info@scmgalaxy.com') ->subject('New image from Devops Team') ->view('dynamic_email_template') ->with('data', $this->imagesendbymailwithstore) ->attach($this->imagesendbymailwithstore['image']->getRealPath(), [ 'as' => $this->imagesendbymailwithstore['image']->getClientOriginalName(), 'mime' => $this->imagesendbymailwithstore['image']->getClientMimeType(), ]);
} }
Next define routes go to your routes/web.php file and paste below code.
Create a Mailable class first you have to create an account in mailtrap or click this url https://mailtrap.io/ after create account you have to copy Username: XXXXXXXXX and password: XXXXXXXXXX and put in .env file see pic
Now we are ready for make mailable class for this we have to go teminal and write following
Letβs go to create controller
php artisan make:controller PDFController
Go to your PDF controller file and paste below code
<?php
namespace App\Http\Controllers; use Log; use PDF; use Mail;
class PDFController extends Controller { /** * Write code on Method * * @return response() */ public function index() { $data["email"] = "laravelamit@gmail.com"; $data["title"] = "From DevOpsSchool.com"; $data["body"] = "This is Demo";
And lastone go to Routes/web.php and paste below code.
<?php
use Illuminate\Support\Facades\Route; use App\Http\Controllers\PDFController;
/* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | */
Route::get('/', function () { return view('welcome'); });
When you are using To Laravel Project with Connect to Api. Then pagination and search filter (laravel default) will not work in this process. So, you can use DataTable or Manual. So in this blog I am using manual.
This is a Search Input filter
This is Pagination
This is Js in script tag
This is First Laravel Project Controller Function for sending requests for pagination and Search Filter.
This is Second Project Controller Function for pagination and search filter.
Next go to dashboard.blade.php and paste below code
<h1>this is dashboard pages</h1>
Now create blog.blade.php file and paste below lines.
<h1>this is blog pages</h1>
Next go to Route/web.php and add below line
Go to Route/web.php
<?php
/* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | */
Route::get('/', function () { return view('welcome'); });
Route::get('/dashboard', function (){ return view('dashboard'); });
Route::get('/create', function (){ return view('create'); });
Route::get('/blog', function (){ return view('blog'); });
Laravel is a web framework built on PHP. That is the code that has been done by PHP. You can use it to create high-end web applications. That is, you can create a very beautiful web application using variables. The Model View Controller architectural pattern follows the design of Laravel. It is created by Tyler Otwell.
Advance of Laravel
Open Source
Collection of Tool
Save time
Improve productivity
Robust And Easy
Security of the application
Authentication
Routing
Templating
Do You Know?
HTML
CSS
JavaScript
SQL
PHP OPP
MVC
Composer
Laravel Requirements
PHP 7.2.0 or Higher
XAMPP (Apache + MariaDB + PHP + Perl)
WAMP/LAMP/MAMP
Composer
Text/code Editor – Notepad++, vs code, ATOM, Brakets
In this tutorial iβm going to describe how to upload multiple image with crud operation edit, update delete in laravel. Image upload is necessary of every project. In this project iβm going to learn how to upload with validation like images, mimes, max file upload and etc, with image preview when uploading image and adding features checklist delete.
After Installation setup database So go to the .env file and add the database credentials. lets go to .env folder and put database name and connect to database.
Next step: Add Resource Route Go to your route and paste below code ππ
use App\Http\Controllers\ProductController; Route::resource('products', ProductController::class);
Now lets go to create controller, model and migration file go to your terminal and paste below code
php artisan make:model ProductController -mcr
Lets go to your migration file productstable and paste below code. π
<?phpuse Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration;class CreateProductsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('products', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); $table->string('detail'); $table->string('image'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('products'); } }
Now migrate the table ππ
php artisan migrate
Next go to Your ProductController file and paste below code ππ
<?php
namespace App\Http\Controllers;
use App\Product; use Illuminate\Http\Request;
class ProductController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $products = Product::latest()->paginate(5);
return redirect()->route('products.index') ->with('success','Product created successfully.'); }
/** * Display the specified resource. * * @param \App\Product $product * @return \Illuminate\Http\Response */ public function show(Product $product) { return view('products.show',compact('product')); }
/** * Show the form for editing the specified resource. * * @param \App\Product $product * @return \Illuminate\Http\Response */ public function edit(Product $product) { return view('products.edit',compact('product')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Product $product * @return \Illuminate\Http\Response */ public function update(Request $request, Product $product) { $request->validate([ 'name' => 'required', 'detail' => 'required' ]);
@if ($errors->any()) <div class="alert alert-danger"> <strong>Whoops!</strong> There were some problems with your input.<br><br> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif
If you want to Compare datetime between two table while selecting record then,
In this function I am using two table First table using from Controller “AllClassController” in this controller, I am taking all data from $slug, and $id. After that I am taking trainer_email and update_at, after that when get value then Other table using Model “Payment” and using where function and taking “$payments_new” and using foreach function and taking which value who required. Same process for Other “$payments_old”.
This is Output “New Enrolled Students Details” and “Old Enrolled Students Details”.
When you using @foreach value in a variable in your blade file and put any value and using any Mathematics function in your value for showing your document this type of error.
In this turoial im going to learn how to upload multiple image in laravel and store in database. Image upload is necessary of every project. In this project iβm going to learn how to upload with validation like images, mimes, max file upload and etc.
So letβs go to download project and configure with database. so copy below code and paste in your terminal.
After Installation setup database So go to the .env file and add the database credentials. lets go to .env folder and put database name and connect to database.
Lets go to create migration file to store the image name go to your terminal and paste below code.
php artisan make:migration create_forms_table
Letβ go to migration table and add file name.
<?php
use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration;
class CreateFormsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('forms', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('filename'); $table->timestamps(); }); }
/** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('forms'); } }
The next step will be to migrate this schema and make a table in the database.
php artisan migrate
Next go to create the controller and model file for this project copy below code and paste in your command. ππ
php artisan make:model Form
php artisan make:controller FormController
lets got to setup the model and controller file for our project.
Step 2: Define routes in the web.php file.
copy below code and paste in your route/web.php file π
<?php
/* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | */
Route::get('/', function () { return view('welcome'); });
$form= new Form(); $form->filename=json_encode($data);
$form->save();
return back()->with('success', 'image has been successfully updated'); }
}
Now, let us make a create.blade.php file inside the Resources/views folder.
@extends('layouts.app') @section('content')
<div class="container"> @if (count($errors) > 0) <div class="alert alert-danger"> <strong>Whoops!</strong> There were some problems with your input.<br><br> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif