mirror of
https://github.com/Aviortheking/CA_LARAVEL.git
synced 2025-04-22 10:52:14 +00:00
Ajout du formulaire contactez-nous | Controller/template_mail
This commit is contained in:
parent
862299aca9
commit
d7d77cc47b
22
.env.example
22
.env.example
@ -7,11 +7,11 @@ APP_URL=http://localhost
|
|||||||
LOG_CHANNEL=stack
|
LOG_CHANNEL=stack
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=mariadb
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
DB_DATABASE=laravel
|
DB_DATABASE=stm
|
||||||
DB_USERNAME=root
|
DB_USERNAME=stm
|
||||||
DB_PASSWORD=
|
DB_PASSWORD=stm
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
@ -23,15 +23,17 @@ REDIS_HOST=127.0.0.1
|
|||||||
REDIS_PASSWORD=null
|
REDIS_PASSWORD=null
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MAIL_DRIVER=smtp
|
MAIL_DRIVER=smtp
|
||||||
MAIL_HOST=smtp.mailtrap.io
|
MAIL_HOST=mail.avior.me
|
||||||
MAIL_PORT=2525
|
MAIL_PORT=587
|
||||||
MAIL_USERNAME=null
|
MAIL_USERNAME= pouet@avior.me
|
||||||
MAIL_PASSWORD=null
|
MAIL_PASSWORD= ****
|
||||||
MAIL_ENCRYPTION=null
|
MAIL_ENCRYPTION=tls
|
||||||
MAIL_FROM_ADDRESS=null
|
|
||||||
MAIL_FROM_NAME="${APP_NAME}"
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
|
||||||
AWS_ACCESS_KEY_ID=
|
AWS_ACCESS_KEY_ID=
|
||||||
AWS_SECRET_ACCESS_KEY=
|
AWS_SECRET_ACCESS_KEY=
|
||||||
AWS_DEFAULT_REGION=us-east-1
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
11
app/ContactUS.php
Normal file
11
app/ContactUS.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ContactUS extends Model
|
||||||
|
{
|
||||||
|
public $table = 'contactus';
|
||||||
|
public $fillable = ['name', 'email', 'message'];
|
||||||
|
}
|
49
app/Http/Controllers/ContactUSController.php
Normal file
49
app/Http/Controllers/ContactUSController.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests;
|
||||||
|
use App\ContactUS;
|
||||||
|
use Mail;
|
||||||
|
|
||||||
|
class ContactUSController extends Controller
|
||||||
|
{
|
||||||
|
public function contactUS()
|
||||||
|
{
|
||||||
|
return view('contactUS');
|
||||||
|
}
|
||||||
|
/** * Show the application dashboard. * * @return \Illuminate\Http\Response */
|
||||||
|
public function contactUSPost(Request $request)
|
||||||
|
{
|
||||||
|
$this->validate($request, ['name' => 'required', 'email' => 'required|email', 'message' => 'required']);
|
||||||
|
ContactUS::create($request->all());
|
||||||
|
|
||||||
|
|
||||||
|
$email_sender = $request->get('email');
|
||||||
|
|
||||||
|
Mail::send(
|
||||||
|
'email',
|
||||||
|
array(
|
||||||
|
'name' => $request->get('name'),
|
||||||
|
'email' => $request->get('email'),
|
||||||
|
'user_message' => $request->get('message')
|
||||||
|
),
|
||||||
|
function ($message) {
|
||||||
|
$message->from('pouet@avior.me');
|
||||||
|
$message->to('brossard.nicolas09@gmail.com', 'Admin')->subject('Super Cours Laravel');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
Mail::send(
|
||||||
|
'email_receipt',
|
||||||
|
array(
|
||||||
|
'name' => $request->get('name'),
|
||||||
|
),
|
||||||
|
function ($message) use ($email_sender) {
|
||||||
|
$message->from('pouet@avior.me');
|
||||||
|
$message->to($email_sender)->subject('Accusé de reception');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return back()->with('success', 'Bien joué mec!');
|
||||||
|
}
|
||||||
|
}
|
33
app/Mail/CA_Laravel.php
Normal file
33
app/Mail/CA_Laravel.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class CA_Laravel extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the message.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function build()
|
||||||
|
{
|
||||||
|
return $this->view('view.name');
|
||||||
|
}
|
||||||
|
}
|
@ -121,6 +121,7 @@ return array(
|
|||||||
'Illuminate\Validation\ValidationServiceProvider',
|
'Illuminate\Validation\ValidationServiceProvider',
|
||||||
'Illuminate\View\ViewServiceProvider',
|
'Illuminate\View\ViewServiceProvider',
|
||||||
'Illuminate\Workbench\WorkbenchServiceProvider',
|
'Illuminate\Workbench\WorkbenchServiceProvider',
|
||||||
|
'Collective\Html\HtmlServiceProvider',
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -135,7 +136,7 @@ return array(
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'manifest' => storage_path().'/meta',
|
'manifest' => storage_path() . '/meta',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@ -164,7 +165,7 @@ return array(
|
|||||||
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
|
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
|
||||||
'Event' => 'Illuminate\Support\Facades\Event',
|
'Event' => 'Illuminate\Support\Facades\Event',
|
||||||
'File' => 'Illuminate\Support\Facades\File',
|
'File' => 'Illuminate\Support\Facades\File',
|
||||||
'Form' => 'Illuminate\Support\Facades\Form',
|
// 'Form' => 'Illuminate\Support\Facades\Form',
|
||||||
'Hash' => 'Illuminate\Support\Facades\Hash',
|
'Hash' => 'Illuminate\Support\Facades\Hash',
|
||||||
'HTML' => 'Illuminate\Support\Facades\HTML',
|
'HTML' => 'Illuminate\Support\Facades\HTML',
|
||||||
'Input' => 'Illuminate\Support\Facades\Input',
|
'Input' => 'Illuminate\Support\Facades\Input',
|
||||||
@ -188,6 +189,8 @@ return array(
|
|||||||
'URL' => 'Illuminate\Support\Facades\URL',
|
'URL' => 'Illuminate\Support\Facades\URL',
|
||||||
'Validator' => 'Illuminate\Support\Facades\Validator',
|
'Validator' => 'Illuminate\Support\Facades\Validator',
|
||||||
'View' => 'Illuminate\Support\Facades\View',
|
'View' => 'Illuminate\Support\Facades\View',
|
||||||
|
'Form' => 'Collective\Html\FormFacade',
|
||||||
|
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
"php": "^7.2",
|
"php": "^7.2",
|
||||||
"fideloper/proxy": "^4.0",
|
"fideloper/proxy": "^4.0",
|
||||||
"laravel/framework": "^6.2",
|
"laravel/framework": "^6.2",
|
||||||
"laravel/tinker": "^2.0"
|
"laravel/tinker": "^2.0",
|
||||||
|
"laravelcollective/html": "^6.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"facade/ignition": "^1.4",
|
"facade/ignition": "^1.4",
|
||||||
|
70
composer.lock
generated
70
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "5ac7407dc851b5e4eb9c002f1ba28c68",
|
"content-hash": "34961f507e8019b81e251a30bf6f859c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "dnoegel/php-xdg-base-dir",
|
"name": "dnoegel/php-xdg-base-dir",
|
||||||
@ -633,6 +633,74 @@
|
|||||||
],
|
],
|
||||||
"time": "2020-02-05T15:00:44+00:00"
|
"time": "2020-02-05T15:00:44+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "laravelcollective/html",
|
||||||
|
"version": "v6.0.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/LaravelCollective/html.git",
|
||||||
|
"reference": "bcc317d21a7e04eebcc81c4109fa84feaab63590"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/LaravelCollective/html/zipball/bcc317d21a7e04eebcc81c4109fa84feaab63590",
|
||||||
|
"reference": "bcc317d21a7e04eebcc81c4109fa84feaab63590",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/http": "^6.0",
|
||||||
|
"illuminate/routing": "^6.0",
|
||||||
|
"illuminate/session": "^6.0",
|
||||||
|
"illuminate/support": "^6.0",
|
||||||
|
"illuminate/view": "^6.0",
|
||||||
|
"php": ">=7.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"illuminate/database": "^6.0",
|
||||||
|
"mockery/mockery": "~1.0",
|
||||||
|
"phpunit/phpunit": "~7.1"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "6.0-dev"
|
||||||
|
},
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Collective\\Html\\HtmlServiceProvider"
|
||||||
|
],
|
||||||
|
"aliases": {
|
||||||
|
"Form": "Collective\\Html\\FormFacade",
|
||||||
|
"Html": "Collective\\Html\\HtmlFacade"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Collective\\Html\\": "src/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/helpers.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Adam Engebretson",
|
||||||
|
"email": "adam@laravelcollective.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Taylor Otwell",
|
||||||
|
"email": "taylorotwell@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "HTML and Form Builders for the Laravel Framework",
|
||||||
|
"homepage": "https://laravelcollective.com",
|
||||||
|
"time": "2019-10-02T00:37:39+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "league/commonmark",
|
"name": "league/commonmark",
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateContactUsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('contactus', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('email');
|
||||||
|
$table->text('message');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::drop("contactus");
|
||||||
|
}
|
||||||
|
}
|
37
resources/views/contactUS.blade.php
Normal file
37
resources/views/contactUS.blade.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Laravel 5.4 Cloudways Contact US Form Example</title>
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1>Contactez-nous</h1>
|
||||||
|
@if(Session::has('success'))
|
||||||
|
<div class="alert alert-success">
|
||||||
|
{{ Session::get('success') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
{!! Form::open(['route'=>'contactus.store']) !!}
|
||||||
|
<div class="form-group {{ $errors->has('name') ? 'has-error' : '' }}">
|
||||||
|
{!! Form::label('Nom:') !!}
|
||||||
|
{!! Form::text('name', old('name'), ['class'=>'form-control', 'placeholder'=>'Enter Name']) !!}
|
||||||
|
<span class="text-danger">{{ $errors->first('name') }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group {{ $errors->has('email') ? 'has-error' : '' }}">
|
||||||
|
{!! Form::label('Email:') !!}
|
||||||
|
{!! Form::text('email', old('email'), ['class'=>'form-control', 'placeholder'=>'Enter Email']) !!}
|
||||||
|
<span class="text-danger">{{ $errors->first('email') }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group {{ $errors->has('message') ? 'has-error' : '' }}">
|
||||||
|
{!! Form::label('Message:') !!}
|
||||||
|
{!! Form::textarea('message', old('message'), ['class'=>'form-control', 'placeholder'=>'Enter Message']) !!}
|
||||||
|
<span class="text-danger">{{ $errors->first('message') }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button class="btn btn-success">Ziiing !</button>
|
||||||
|
</div>
|
||||||
|
{!! Form::close() !!}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
10
resources/views/email.blade.php
Normal file
10
resources/views/email.blade.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Vous avez un message de : {{ $name }}
|
||||||
|
<p>
|
||||||
|
Name: {{ $name }}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Email: {{ $email }}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Message: {{ $user_message }}
|
||||||
|
</p>
|
6
resources/views/email_receipt.blade.php
Normal file
6
resources/views/email_receipt.blade.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<h1>
|
||||||
|
|
||||||
|
Merci {{ $name }} pour votre message.
|
||||||
|
|
||||||
|
</h1>
|
||||||
|
|
@ -14,3 +14,6 @@
|
|||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
return view('welcome');
|
return view('welcome');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::get('contact-us', 'ContactUSController@contactUS');
|
||||||
|
Route::post('contact-us', ['as' => 'contactus.store', 'uses' => 'ContactUSController@contactUSPost']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user