Skip to content

Commit

Permalink
Avored Contact Module
Browse files Browse the repository at this point in the history
  • Loading branch information
indpurvesh committed Apr 28, 2018
1 parent c560ba0 commit c38b1cb
Show file tree
Hide file tree
Showing 13 changed files with 347 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# contact
AvoRed E commerce Contact Module
# AvoRed E commerce Dummy Data

AvoRed E commerce Dummy Data
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "avored/contact",
"type": "avored-module",
"description": "AvoRed Laravel 5 E commerce Contact Module",
"keywords": ["framework", "contact" ,"cart","laravel","e commerce","laravel5","shop","shopping-cart","e-commerce","shopping cart","e commerce"],
"license": "MIT",
"authors": [
{
"name": "Purvesh ",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=7.0.0",
"avored/module-installer": "dev-master"
},
"autoload": {
"psr-4": {
"AvoRed\\Contact\\": "src"

}
}
}
3 changes: 3 additions & 0 deletions register.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
identifier: avored-contact
description: AvoRed Contact Module
namespace: AvoRed\Contact\
10 changes: 10 additions & 0 deletions resources/lang/en/contact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

<?php


return [




];
39 changes: 39 additions & 0 deletions resources/views/contact/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@extends('layouts.app')

@section('meta_title')
Contact US
@endsection

@section('content')
<div class="row">

<div class="col-md-12">

<h1>Contact US</h1>
<div class="">
<form action="{{ route('contact.send') }}" method="post">
@csrf

@include('partials.forms.text',['name' => 'name','label' => 'Name'])
@include('partials.forms.text',['name' => 'email','label' => 'Email'])
@include('partials.forms.text',['name' => 'phone','label' => 'Phone'])

<div class="form-group">
<label for="message">Message</label>
<textarea class="form-control{{ $errors->has('message') ? " is-invalid" : "" }}" name="message" id="messge"></textarea>

@if($errors->has('message'))
<div class="invalid-feedback">
{{ $errors->first('message') }}
</div>
@endif
</div>

<button type="submit" class="btn btn-primary" >Send</button>
</form>

</div>
</div>

</div>
@endsection
13 changes: 13 additions & 0 deletions resources/views/mails/contact-acknoledgement.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@component('mail::message')


@component('mail::panel')
# Contact Message Received

You received this email as an acknoledgement because you send an inquiry thorough AvoRed Contact us form.
We are happy to tell you that we have received your email and we will be in touch soon.
@endcomponent

Thanks,
AvoRed
@endcomponent
11 changes: 11 additions & 0 deletions resources/views/mails/contact-request.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@component('mail::message')

# Contact Message Received

Name: {{ $name }}
Email: {{ $email }}
Phone: {{ $phone }}
Message: {{ $message }}

Thanks
@endcomponent
22 changes: 22 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
|--------------------------------------------------------------------------
| AvoRed E commerce Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an avored user modules.
| It's a breeze. Simply tell avored user module the URI it should respond to
| and give it the controller to call when that URI is requested.
|
*/


Route::middleware(['web'])
->namespace('AvoRed\Contact\Http\Controllers')
->group(function () {
Route::get('contact', 'ContactController@index')->name('contact.index');

Route::post('contact', 'ContactController@send')->name('contact.send');

});
34 changes: 34 additions & 0 deletions src/Http/Controllers/ContactController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace AvoRed\Contact\Http\Controllers;

use AvoRed\Contact\Http\Requests\ContactRequest;
use AvoRed\Ecommerce\Models\Database\Configuration;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use AvoRed\Contact\Mails\ContactMail;
use AvoRed\Contact\Mails\ContactMailRequest;
use Illuminate\Support\Facades\Mail;

class ContactController extends Controller
{
public function index() {
return view('avored-contact::contact.index');
}

public function send(ContactRequest $request) {
//return $request->all();

$configuration = new Configuration();
$adminEmail = $configuration->getConfiguration('general_administrator_email');

// Sent an EMail to AvoRed Administrator
Mail::to($adminEmail)->send(new ContactMailRequest($request));

// Sent an EMail to AvoRed Administrator
Mail::to($request->get('email'))->send(new ContactMail());


return redirect()->route('contact.index')->with('successNotification', 'Your Request has been sent!');
}
}
33 changes: 33 additions & 0 deletions src/Http/Requests/ContactRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace AvoRed\Contact\Http\Requests;

use Illuminate\Foundation\Http\FormRequest as Request;

class ContactRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$validation['name'] = 'required|max:255';
$validation['email'] = 'required|email|max:255';
$validation['phone'] = 'required|min:6';
$validation['message'] = 'required|min:6';

return $validation;
}
}
24 changes: 24 additions & 0 deletions src/Mails/ContactMail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace AvoRed\Contact\Mails;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class ContactMail extends Mailable
{
use Queueable, SerializesModels;



/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('avored-contact::mails.contact-acknoledgement');
}
}
59 changes: 59 additions & 0 deletions src/Mails/ContactMailRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace AvoRed\Contact\Mails;

use AvoRed\Contact\Http\Requests\ContactRequest;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class ContactMailRequest extends Mailable
{
use Queueable, SerializesModels;

/**
* @var $name
*/
public $name;

/**
* @var $phone
*/
public $phone;

/**
* @var $email
*/
public $email;

/**
* @var $message
*/
public $message;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct(ContactRequest $request)
{
$this->name = $request->get('name');
$this->phone = $request->get('phone');
$this->email = $request->get('email');
$this->message = $request->get('message');

}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->replyTo($this->email, $this->name)
->markdown("avored-contact::mails.contact-request");

}
}
72 changes: 72 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
namespace AvoRed\Contact;

use Illuminate\Support\ServiceProvider;
use AvoRed\Framework\Menu\Menu;
use AvoRed\Framework\Menu\Facade as MenuFacade;

class Module extends ServiceProvider
{

/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->registerResources();
$this->registerFrontMenu();
$this->publishFiles();

}

/**
* Register any application services.
*
* @return void
*/
public function register()
{

}

/**
* Registering AvoRed Contact Resource
* e.g. Route, View, Database & Translation Path
*
* @return void
*/
protected function registerResources()
{
$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'avored-contact');
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'avored-contact');
}

/**
* Register the Publish Files
*
* @return void
*/
public function publishFiles()
{
$this->publishes([
__DIR__ . '/../resources/views' => base_path('themes/avored/default/views/vendor')
],'avored-module-views');
}

/**
* Register the Menus.
*
* @return void
*/
protected function registerFrontMenu()
{
MenuFacade::make('contact-us',function (Menu $accountMenu){
$accountMenu->label('Contact Us')
->route('contact.index');
});

}
}

0 comments on commit c38b1cb

Please sign in to comment.