Как использовать готовую загрузку здесь, я имею в виду, просто используя одну переменную вместо двух. Так что мне не нужно запускать два отдельных запроса

1) Как можно использовать нетерпеливую загрузку здесь, я имею в виду, просто используя $ SponceringUser вместо $ ProfileUser. поэтому мне не нужно запускать два отдельных запроса.

если я обменяю переменную $ profileUser на $ SponceringUser, где в коде я должен сохранить ее, чтобы получить правильный вывод

Вот метод Post_edit для более подробной информации, пожалуйста, обратитесь к Гисте здесь: https://gist.github.com/gupta2205/b33dcf762876e5df34d9

public function post_edit($id = null)
{
if ($id)
{
$Petition = Petition::find($id);

if (!$Petition)
{
//oh noes! invalid petition specified!
Alert::error("That petition no longer exists");
return Redirect::action('AdminPetitionsController@index');
}
}
else
{
$Petition = new Petition;
}

$PetitionCreationForm = new AdminPetitionCreationForm;
$errors = array();

if ($PetitionCreationForm->passes())
{
$Petition->call_to_action = Input::get('call_to_action');

if (empty($Petition->id))
{
$Petition->slug = Str::slug($Petition->call_to_action);
}

$Petition->recipient = Input::get('recipient');if (Input::get('feature_type') == '1')
{
$Petition->featured_sort_order = Input::get('featured_sort_order') + 1;
$Petition->flag_featured = 1;
}
else if(Input::get('feature_type') == '0')
{
$Petition->featured_sort_order=null;
$Petition->flag_featured = 0;
}
//$selected_position = Input::get('dropdown_menu_list');
$Petition->description_md = Input::get('description_md');
$Petition->description = Petition::parseMD($Petition->description_md);

$Petition->letter_md = Input::get('letter_md');
$Petition->letter = Petition::parseMD($Petition->letter_md);

$Petition->target_signatures = Input::get('target_signatures', 50000);
$Petition->flag_published = Input::get('flag_published');

$Petition->media_type = Input::get('media_type', null);

if (Input::get('media_type') == 'img' && Input::hasFile('petition_image'))
{
$Petition->media_url = Petition::uploadFile(Input::file('petition_image'));
}
else if (Input::get('media_type') == 'youtube' && Input::get('media_url_youtube'))
{
$Petition->media_url = Input::get('media_url_youtube');
}//  how to fix this part .... gurrrrrrrrrrrr=======================
$ProfileUser= $Petition->User;

if (Input::get('profile_type') == 'image' && Input::hasFile('profile_image'))
{
$ProfileUser->profile_img_url =  Petition::uploadFile(Input::file('profile_image'));
}
else if (Input::get('profile_type') == 'url' && Input::get('profile_url'))
{
$ProfileUser->profile_img_url = Input::get('profile_url');
}
//$Petition->sponsor_user_id = $SponsoringUser->id;
$ProfileUser->save();
//====================================================

try {
try {
$SponsoringUser = User::where('email', Input::get('user.email'))->firstOrFail();
}
catch (Exception $e)
{
$PetitionSponsorForm = new AdminPetitionSponsorForm(Input::get('user'));

if ($PetitionSponsorForm->passes())
{
$SponsoringUser = new User;
$SponsoringUser->email = Input::get('user.email');
$SponsoringUser->first_name = Input::get('user.first_name');
$SponsoringUser->last_name = Input::get('user.last_name');
$SponsoringUser->populateLocation(Input::get('user.zip'));

$SponsoringUser->save();
}
else
{
throw new Exception();
}
}
$Petition->save();

1) Как можно использовать нетерпеливую загрузку здесь, я имею в виду, просто используя $ SponceringUser вместо $ ProfileUser. поэтому мне не нужно запускать два отдельных запроса.

0

Решение

я понял 🙂

 if (Input::get('profile_type') == 'image' && Input::hasFile('profile_image'))
{
$SponsoringUser->profile_img_url =           Petition::uploadFile(Input::file('profile_image'));
}
else if (Input::get('profile_type') == 'url' && Input::get('profile_url'))
{
$$SponsoringUser->profile_img_url = Input::get('profile_url');
}

$SponsoringUser->save();
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector