Created
August 30, 2016 20:32
-
-
Save htunnicliff/5d1df0e7f4f63e77fc209a031aeb4129 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use App\Http\Requests; | |
use App\User; | |
use App\Email; | |
use App\Element; | |
use App\Template; | |
class EmailController extends Controller | |
{ | |
/** | |
* Display a listing of the resource. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function index() | |
{ | |
$emails = Email::all(); | |
return view('emails.index', compact('emails')); | |
} | |
/** | |
* Show the form for creating a new resource. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function create(Request $request, Template $template) | |
{ | |
$templates = Template::all(); | |
return view('emails.create', compact('templates')); | |
} | |
/** | |
* Store a newly created resource in storage. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return \Illuminate\Http\Response | |
*/ | |
public function store(Request $request) | |
{ | |
$email = new Email; | |
$email->name = $request->name; | |
$email->template = $request->template; | |
$email->createdBy = $request->user()->name; | |
$email->save(); | |
return redirect()->to('/emails/'. $email->id . '/edit'); | |
} | |
/** | |
* Display the specified resource. | |
* | |
* @param int $id | |
* @return \Illuminate\Http\Response | |
*/ | |
public function show($id) | |
{ | |
$email = Email::findOrFail($id); | |
return view('emails.show', compact('email')); | |
} | |
/** | |
* Show the form for editing the specified resource. | |
* | |
* @param int $id | |
* @return \Illuminate\Http\Response | |
*/ | |
public function edit($id, Email $email) | |
{ | |
$email = Email::findOrFail($id); | |
$template = Template::where('name', 'Undergraduate')->first(); | |
return view('emails.edit', compact('email', 'template')); | |
} | |
/** | |
* Update the specified resource in storage. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param int $id | |
* @return \Illuminate\Http\Response | |
*/ | |
public function update(Request $request, $id) | |
{ | |
// | |
} | |
public function preview($id) | |
{ | |
// $email = Email::findOrFail($id); | |
// $preview = makeTemplate($id); | |
// return $preview; | |
// PLACEHOLDER | |
return redirect('templates/1'); | |
} | |
/** | |
* Remove the specified resource from storage. | |
* | |
* @param int $id | |
* @return \Illuminate\Http\Response | |
*/ | |
public function destroy($id) | |
{ | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment