/** * Store a newly created resource in storage. * * @return Response */ public function store(ContactFormRequest $request) { $contact = new Contact(); $contact->name = $request->get('fullname'); $contact->phone = $request->get('phone'); $contact->email = $request->get('email'); $contact->content = $request->get('content'); $contact->save(); return redirect()->back()->with('Mess', 'Đã gửi thông tin thành công'); }
/** * @testdox Assets have zero or more Contacts. * @test */ public function contacts() { $asset = new Asset(); $asset->identifier = 'TEST123'; $asset->save(); $contact = new Contact(); $contact->name = 'Bill'; $contact->save(); $asset->contacts()->attach($contact->id); $this->assertEquals(1, $asset->contacts->count()); $this->assertEquals(1, $contact->assets->count()); }
public function createForAsset(Request $request) { // Get the Asset. $assetId = $request->input('asset_id'); $asset = Asset::find($assetId); if (!$asset) { $this->alert('error', "No Asset #{$assetId}", false); return $this->view; } // Save the Contact. $contact = new Contact(); $contact->name = $request->input('name'); $contact->phone_1 = $request->input('phone_1'); $contact->phone_2 = $request->input('phone_2'); $contact->save(); // Then connect the two. $asset->contacts()->attach($contact->id); return redirect("assets/{$asset->id}#contacts"); }