本文整理汇总了PHP中app\models\Contact::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::create方法的具体用法?PHP Contact::create怎么用?PHP Contact::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Contact
的用法示例。
在下文中一共展示了Contact::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* store Contact
*
* @param Business $business Business that will hold the Contact
* @param ContactFormRequest $request Contact form Request
* @return Response Rendered view or Redirect
*/
public function store(Business $business, ContactFormRequest $request)
{
$this->log->info(__METHOD__);
$this->log->info(sprintf("businessId:%s", $business->id));
if (Gate::denies('manageContacts', $business)) {
abort(403);
}
//////////////////
// FOR REFACTOR //
//////////////////
if (trim($request->input('nin'))) {
$existing_contacts = Contact::whereNotNull('nin')->where(['nin' => $request->input('nin')])->get();
foreach ($existing_contacts as $existing_contact) {
$this->log->info(" [ADVICE] Found existing contactId:{$existing_contact->id}");
if ($existing_contact->isSubscribedTo($business)) {
$this->log->info(" [ADVICE] Existing contact is already linked to business");
Flash::warning(trans('manager.contacts.msg.store.warning_showing_existing_contact'));
return redirect()->route('manager.business.contact.show', [$business, $existing_contact]);
}
}
}
$contact = Contact::create($request->except('notes', '_token'));
$business->contacts()->attach($contact);
$business->save();
$this->log->info(" Contact created contactId:{$contact->id}");
if ($request->get('notes')) {
$business->contacts()->find($contact->id)->pivot->update(['notes' => $request->get('notes')]);
}
event(new NewRegisteredContact($contact));
Flash::success(trans('manager.contacts.msg.store.success'));
return redirect()->route('manager.business.contact.show', [$business, $contact]);
}
示例2: postImport
/**
* post Import
*
* @param Business $business Business to import Contacts to
* @param Request $request Submitted form data
* @return Response Redirect to Business addressbook
*/
public function postImport(Business $business, Request $request)
{
$this->log->info(__METHOD__);
$this->log->info(sprintf(" businessId:%s", $business->id));
//////////////////
// FOR REFACTOR //
//////////////////
$csv = $this->csvToArray(Request::get('data'));
foreach ($csv as $import) {
$import = array_map(function ($item) {
return $item == 'NULL' ? null : $item;
}, $import);
if ($import['birthdate'] !== null) {
$date = \DateTime::createFromFormat('Ymd', $import['birthdate']);
$import['birthdate'] = $date->format('m/d/Y');
}
$notes = $import['notes'];
unset($import['notes']);
$contact = Contact::create($import);
$business->contacts()->attach($contact, ['notes' => $notes]);
$business->save();
}
$count = count($csv);
$this->log->info(" Imported {$count} contacts");
Notifynder::category('user.importedContacts')->from('App\\Models\\User', auth()->user()->id)->to('App\\Models\\Business', $business->id)->url('http://localhost')->extra(compact('count'))->send();
Flash::success(trans('manager.contacts.msg.import.success'));
return redirect()->route('manager.business.contact.index', [$business]);
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$lipsum = new LoremIpsumGenerator();
Role::create(['title' => 'Administrator', 'slug' => 'admin']);
Role::create(['title' => 'Redactor', 'slug' => 'redac']);
Role::create(['title' => 'User', 'slug' => 'user']);
User::create(['username' => 'GreatAdmin', 'email' => 'fathir.irhas@outlook.com', 'password' => bcrypt('admin'), 'seen' => true, 'role_id' => 1, 'confirmed' => true]);
User::create(['username' => 'GreatRedactor', 'email' => 'fatheer.eerhas@gmail.com', 'password' => bcrypt('redac'), 'seen' => true, 'role_id' => 2, 'valid' => true, 'confirmed' => true]);
User::create(['username' => 'Walker', 'email' => 'fathir139@yahoo.co.id', 'password' => bcrypt('walker'), 'role_id' => 3, 'confirmed' => true]);
User::create(['username' => 'Slacker', 'email' => 'slacker@la.fr', 'password' => bcrypt('slacker'), 'role_id' => 3, 'confirmed' => true]);
Contact::create(['name' => 'Dupont', 'email' => 'dupont@la.fr', 'text' => 'Lorem ipsum inceptos malesuada leo fusce tortor sociosqu semper, facilisis semper class tempus faucibus tristique duis eros, cubilia quisque habitasse aliquam fringilla orci non. Vel laoreet dolor enim justo facilisis neque accumsan, in ad venenatis hac per dictumst nulla ligula, donec mollis massa porttitor ullamcorper risus. Eu platea fringilla, habitasse.']);
Contact::create(['name' => 'Durand', 'email' => 'durand@la.fr', 'text' => ' Lorem ipsum erat non elit ultrices placerat, netus metus feugiat non conubia fusce porttitor, sociosqu diam commodo metus in. Himenaeos vitae aptent consequat luctus purus eleifend enim, sollicitudin eleifend porta malesuada ac class conubia, condimentum mauris facilisis conubia quis scelerisque. Lacinia tempus nullam felis fusce ac potenti netus ornare semper molestie, iaculis fermentum ornare curabitur tincidunt imperdiet scelerisque imperdiet euismod.']);
Contact::create(['name' => 'Martin', 'email' => 'martin@la.fr', 'text' => 'Lorem ipsum tempor netus aenean ligula habitant vehicula tempor ultrices, placerat sociosqu ultrices consectetur ullamcorper tincidunt quisque tellus, ante nostra euismod nec suspendisse sem curabitur elit. Malesuada lacus viverra sagittis sit ornare orci, augue nullam adipiscing pulvinar libero aliquam vestibulum, platea cursus pellentesque leo dui. Lectus curabitur euismod ad, erat.', 'seen' => true]);
Tag::create(['tag' => 'Tag1']);
Tag::create(['tag' => 'Tag2']);
Tag::create(['tag' => 'Tag3']);
Tag::create(['tag' => 'Tag4']);
Post::create(['title' => 'Post 1', 'slug' => 'post-1', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/mega-champignon.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => $lipsum->getContent(500), 'active' => true, 'user_id' => 1]);
Post::create(['title' => 'Post 2', 'slug' => 'post-2', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/goomba.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => '<p>Lorem ipsum convallis ac curae non elit ultrices placerat netus metus feugiat, non conubia fusce porttitor sociosqu diam commodo metus in himenaeos, vitae aptent consequat luctus purus eleifend enim sollicitudin eleifend porta. Malesuada ac class conubia condimentum mauris facilisis conubia quis scelerisque lacinia, tempus nullam felis fusce ac potenti netus ornare semper. Molestie iaculis fermentum ornare curabitur tincidunt imperdiet scelerisque, imperdiet euismod scelerisque torquent curae rhoncus, sollicitudin tortor placerat aptent hac nec. Posuere suscipit sed tortor neque urna hendrerit vehicula duis litora tristique congue nec auctor felis libero, ornare habitasse nec elit felis inceptos tellus inceptos cubilia quis mattis faucibus sem non.</p>
<p>Odio fringilla class aliquam metus ipsum lorem luctus pharetra dictum, vehicula tempus in venenatis gravida ut gravida proin orci, quis sed platea mi quisque hendrerit semper hendrerit. Facilisis ante sapien faucibus ligula commodo vestibulum rutrum pretium, varius sem aliquet himenaeos dolor cursus nunc habitasse, aliquam ut curabitur ipsum luctus ut rutrum. Odio condimentum donec suscipit molestie est etiam sit rutrum dui nostra, sem aliquet conubia nullam sollicitudin rhoncus venenatis vivamus rhoncus netus, risus tortor non mauris turpis eget integer nibh dolor. Commodo venenatis ut molestie semper adipiscing amet cras, class donec sapien malesuada auctor sapien arcu inceptos, aenean consequat metus litora mattis vivamus.</p>
<pre>
<code class="language-php">protected function getUserByRecaller($recaller)
{
if ($this->validRecaller($recaller) && ! $this->tokenRetrievalAttempted)
{
$this->tokenRetrievalAttempted = true;
list($id, $token) = explode("|", $recaller, 2);
$this->viaRemember = ! is_null($user = $this->provider->retrieveByToken($id, $token));
return $user;
}
}</code></pre>
<p>Feugiat arcu adipiscing mauris primis ante ullamcorper ad nisi, lobortis arcu per orci malesuada blandit metus tortor, urna turpis consectetur porttitor egestas sed eleifend. Eget tincidunt pharetra varius tincidunt morbi malesuada elementum mi torquent mollis, eu lobortis curae purus amet vivamus amet nulla torquent, nibh eu diam aliquam pretium donec aliquam tempus lacus. Tempus feugiat lectus cras non velit mollis sit et integer, egestas habitant auctor integer sem at nam massa himenaeos, netus vel dapibus nibh malesuada leo fusce tortor. Sociosqu semper facilisis semper class tempus faucibus tristique duis eros, cubilia quisque habitasse aliquam fringilla orci non vel, laoreet dolor enim justo facilisis neque accumsan in.</p>
<p>Ad venenatis hac per dictumst nulla ligula donec, mollis massa porttitor ullamcorper risus eu platea, fringilla habitasse suscipit pellentesque donec est. Habitant vehicula tempor ultrices placerat sociosqu ultrices consectetur ullamcorper tincidunt quisque tellus, ante nostra euismod nec suspendisse sem curabitur elit malesuada lacus. Viverra sagittis sit ornare orci augue nullam adipiscing pulvinar libero aliquam vestibulum platea cursus pellentesque leo dui lectus, curabitur euismod ad erat curae non elit ultrices placerat netus metus feugiat non conubia fusce porttitor. Sociosqu diam commodo metus in himenaeos vitae aptent consequat luctus purus eleifend enim sollicitudin eleifend, porta malesuada ac class conubia condimentum mauris facilisis conubia quis scelerisque lacinia.</p>
<p>Tempus nullam felis fusce ac potenti netus ornare semper molestie iaculis, fermentum ornare curabitur tincidunt imperdiet scelerisque imperdiet euismod. Scelerisque torquent curae rhoncus sollicitudin tortor placerat aptent hac, nec posuere suscipit sed tortor neque urna hendrerit, vehicula duis litora tristique congue nec auctor. Felis libero ornare habitasse nec elit felis, inceptos tellus inceptos cubilia quis mattis, faucibus sem non odio fringilla. Class aliquam metus ipsum lorem luctus pharetra dictum vehicula, tempus in venenatis gravida ut gravida proin orci, quis sed platea mi quisque hendrerit semper.</p>
', 'active' => true, 'user_id' => 2]);
Post::create(['title' => 'Post 3', 'slug' => 'post-3', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/rouge-shell.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => $lipsum->getContent(500), 'active' => true, 'user_id' => 2]);
Post::create(['title' => 'Post 4', 'slug' => 'post-4', 'summary' => '<img alt="" src="/filemanager/userfiles/user2/rouge-shyguy.png" style="float:left; height:128px; width:128px" />' . $lipsum->getContent(50), 'content' => $lipsum->getContent(500), 'active' => true, 'user_id' => 2]);
PostTag::create(['post_id' => 1, 'tag_id' => 1]);
PostTag::create(['post_id' => 1, 'tag_id' => 2]);
PostTag::create(['post_id' => 2, 'tag_id' => 1]);
PostTag::create(['post_id' => 2, 'tag_id' => 2]);
PostTag::create(['post_id' => 2, 'tag_id' => 3]);
PostTag::create(['post_id' => 3, 'tag_id' => 1]);
PostTag::create(['post_id' => 3, 'tag_id' => 2]);
PostTag::create(['post_id' => 3, 'tag_id' => 4]);
Comment::create(['content' => $lipsum->getContent(200), 'user_id' => 2, 'post_id' => 1]);
Comment::create(['content' => $lipsum->getContent(200), 'user_id' => 2, 'post_id' => 2]);
Comment::create(['content' => $lipsum->getContent(200), 'user_id' => 3, 'post_id' => 1]);
}
示例4: postContact
public function postContact(Request $request)
{
$this->validate($request, ['name' => 'required|min:3', 'email' => 'required|email', 'content' => 'required|min:10']);
\DB::transaction(function () use($request) {
Contact::create($request->all());
});
session()->flash('message', ['success', 'Thanks for contacting us, we\'ve received your request, be with you soon!']);
return redirect('/');
}
示例5: copyFrom
/**
* Copy Contact from provided exiting.
*
* @param User $user
* @param Business $business
* @param Contact $existingContact
*
* @return App\Models\Contact
*/
public function copyFrom(User $user, Business $business, Contact $existingContact)
{
$contact = Contact::create($existingContact->toArray());
$contact->user()->associate($user->id);
$contact->businesses()->detach();
$contact->save();
$business->contacts()->attach($contact);
$business->save();
return $contact;
}
示例6: register
/**
* Register a new Contact.
*
* @param User $user
* @param Business $business
* @param array $data
*
* @return App\Models\Contact
*/
public function register(User $user, Business $business, $data)
{
if (false === ($contact = self::getExisting($user, $business, $data['nin']))) {
$contact = Contact::create($data);
$business->contacts()->attach($contact);
logger()->info("Contact created contactId:{$contact->id}");
self::updateNotes($business, $contact, $data['notes']);
}
event(new NewRegisteredContact($contact));
return $contact;
}
示例7: run
public function run()
{
$this->command->info('Running UserTableSeeder');
Eloquent::unguard();
$faker = Faker\Factory::create();
$company = Company::create();
$account = Account::create(['name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => Country::all()->random()->id, 'account_key' => str_random(RANDOM_KEY_LENGTH), 'invoice_terms' => $faker->text($faker->numberBetween(50, 300)), 'work_phone' => $faker->phoneNumber, 'work_email' => $faker->safeEmail, 'invoice_design_id' => InvoiceDesign::where('id', '<', CUSTOM_DESIGN)->get()->random()->id, 'header_font_id' => min(Font::all()->random()->id, 17), 'body_font_id' => min(Font::all()->random()->id, 17), 'primary_color' => $faker->hexcolor, 'timezone_id' => 1, 'company_id' => $company->id]);
$user = User::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD), 'registered' => true, 'confirmed' => true, 'notify_sent' => false, 'notify_paid' => false, 'is_admin' => 1]);
$client = Client::create(['user_id' => $user->id, 'account_id' => $account->id, 'public_id' => 1, 'name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => DEFAULT_COUNTRY, 'currency_id' => DEFAULT_CURRENCY]);
Contact::create(['user_id' => $user->id, 'account_id' => $account->id, 'client_id' => $client->id, 'public_id' => 1, 'email' => env('TEST_EMAIL', TEST_USERNAME), 'is_primary' => true]);
Product::create(['user_id' => $user->id, 'account_id' => $account->id, 'public_id' => 1, 'product_key' => 'ITEM', 'notes' => 'Something nice...', 'cost' => 10]);
Affiliate::create(['affiliate_key' => SELF_HOST_AFFILIATE_KEY]);
}
示例8: postContact
public function postContact(FormContactRequest $request)
{
if (!empty($request)) {
$data = $request->all();
$data['customer_id'] = Auth::customer()->user()->id;
$data['flagactive'] = $request->get('flagactive', 1);
if ($request->id) {
$obj = Contact::find($request->id);
$obj->update($data);
} else {
$obj = Contact::create($data);
}
return array('msg' => 'ok', 'state' => 1, 'data' => null);
}
return array('msg' => 'Error al guardar el modelo', 'state' => 0, 'data' => null);
}
示例9: save_contact
public function save_contact(Request $request)
{
$validator = Validator::make($request->all(), ['phone' => 'required|digits:10', 'email' => 'required|email', 'fullname' => ['required', 'regex:/^[A-Za-zАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя\\s]+$/']]);
//dd($validator->messages());
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput();
}
if ($request->has('id')) {
$current_contact = Contact::find($request->input('id'));
$current_contact->phone = $request->input('phone');
$current_contact->fullname = $request->input('fullname');
$current_contact->email = $request->input('email');
$current_contact->save();
} else {
Contact::create($request->all());
}
return redirect()->route('home');
}
示例10: contact
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function contact(Request $request)
{
$this->validate($request, ['name' => 'required|min:3|max:255', 'email' => 'required|email', 'contact_no' => 'numeric|min:10', 'subject' => 'required', 'message' => 'required']);
Mail::send('emails.contact_admin', array('input' => Input::get()), function ($message) {
$message->from(Input::get('email'), Input::get('name'))->to(env('MAIL_FROM_EMAIL'), env('MAIL_FROM_NAME'))->subject('Received new request');
});
Mail::send('emails.contact_user', array(), function ($message) {
$message->to(Input::get('email'), Input::get('name'))->subject('Thanks for contacting us.');
});
Contact::create(Input::get());
if (Input::get('subscribe')) {
$subscriber = Subscriber::where('email', '=', Input::get('email'))->first();
if (!isset($subscriber->exists)) {
$subscriber_create = Subscriber::create(Input::get());
}
}
return response()->json(['message' => 'Thanks for your request. Our representative will contact you soon.']);
}
示例11: view
return view('about');
});
Route::get('/contact', function () {
return view('contact');
});
Route::get('/projects', function () {
$projects = Project::where('active', 1)->get();
return view('projects', ['projects' => $projects]);
});
Route::post('/contact', function (Request $request) {
$name = $request->input('name');
$email = $request->input('email');
$message = $request->input('message');
if ($email && $name && $message) {
$contactData = ['name' => $name, 'email' => $email, 'message' => $message];
Contact::create($contactData);
}
dispatch(new \App\Jobs\SendContactEmail($name, $email, $message));
return view('mailSent');
});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::group(['middleware' => ['web']], function () {
示例12: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
foreach (range(1, 20) as $number) {
\App\models\Contact::create(['name' => '名稱', 'email' => '電郵地址', 'message' => '內容', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
}
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
Contact::create($request->all());
Session::flash('flash_message', 'Contact added!');
return redirect('contacts');
}
示例14: storeContact
public function storeContact(ContactRequest $request)
{
try {
$inputs = $request->all();
Contact::create($inputs);
$message = "Cảm ơn bạn đã đóng góp ý kiến. ChickenElectric sẽ nhanh chóng phản hồi lại.";
$alertClass = "alert-success";
return redirect(route('website.contact.index'))->with(compact('message', 'alertClass'));
} catch (Exception $e) {
$message = "Tin nhắn không thể gửi đi";
$alertClass = "alert-danger";
return redirect(route('website.contact.index'))->with(compact('message', 'alertClass'))->withInput();
}
}
示例15: updateContact
public function updateContact()
{
$contact = new Contact();
$request = (object) $_POST;
$contact->create($request->direccion, $request->correo, $request->telefono, $request->descripcion);
newFlashMessage('test', 'Informacion de contacto actualizada.');
return redirect('admin/contact');
}