vendredi 1 juillet 2016

Update an xml element using where condition

I have an xml file fonts.xml

<fonts>

 <font>

   <name>Aclonica</name>
   <category>Aclonica</category>
   <variants>100,bold</variants>
   <status>active</status>

 </font>
 <font>

   <name>Azeebe</name>
   <category>Sans-serif</category>
   <variants>100,bold,italic</variants>
   <status>active</status>

 </font>

</fonts>

i want to update the status of the node where the name is "Aclonica". How to do this please help me.



via Chebli Mohamed

passing pivot table views to laravel

I have seen some of the question here but none of them have solved my problem.I am confused. I have a many to many relation between community and idea model. it is saving values in pivot table perfectly but i am unable to fetch data to view.

Idea Model: public function communities() { return $this->belongsToMany('App\Community', "community_idea"); }

Community model:

public function ideas() {
    return $this->belongsToMany('App\Idea', "community_idea");
}

Store Post Function:

//function for creating Idea
public function storePost(IdeaRequest $request)
{
    if ($request->hasFile('idea_image')) {
        $filename = $request->file('idea_image')->getClientOriginalName();
        $moveImage = $request->file('idea_image')->move('images/', $filename);
    }
    $idea = new Idea();
    $idea->idea_title = $request->input('idea_title');
    $idea->user_id = Auth::id();
    $idea->idea_image = $moveImage;
    $idea->idea_info = $request->input('idea_info');
    $idea->idea_location = $request->input('idea_location');
    $idea->idea_goal = $request->input('idea_goal');
    $idea->idea_description = strip_tags($request->input('idea_description'));
    $idea->save();
    $idea->communities()->attach($request->input('selection'));
    Session::set('idea_id',$idea->id);
    session()->flash('flash_message', 'Your idea has been submitted for Review, Kindly Fill this Work BreakDown of You Work');
    return redirect()->route('create_wbs');
}

VIEW: When i try to use this, it throws

Undefined property: Illuminate\Pagination\LengthAwarePaginator::$communities` error @foreach($ideas->communities as $idea) @if($idea->status == 1)

     <div class="top-project-info">
     <div class="content-info-short clearfix">
     <a href="" class="thumb-img">
     <img src="" alt="">
     </a>
     <div class="wrap-short-detail">
     <h3 class="rs acticle-title"><a class="be-fc-orange" href=""><q></q></a></h3>
     <p class="rs tiny-desc">by <a href="#" class="fw-b fc-gray be-fc-orange"></a></p>
     <p class="rs title-description"></p>
     <p class="rs project-location">
     <i class="icon iLocation"></i>
     
     </p>
     </div>
    </div>
  </div>
</div>
</div><!--end: .grid_3 > .project-short-->
  @endif
@endforeach



via Chebli Mohamed

Blade variable in Javascript

I have a controller which will save a widget(html elements and contents).My problem now is I cant use the variable from the controller as a value in Javascript variable

in view

updateLayout = function(){
  var html={!! $widgets !!};
    $('#sortable_portlets').html(html);  
}

which then show the error in console

Uncaught SyntaxError: Unexpected token <

the line that error

 updateLayout = function(){
  var html=
<div class="col-md-4 column sortable">//show red x

My controller

$widgets = Widgets::all()->last();
    $dd=$widgets->html;
    return view('tvproject.partA', array(
        'widgets' => $dd
    ));

Passing directly to the blade template

 

Result

 -icon ui-icon-gripsmall-diagonal-se" style="z-index: 90;"></div></div> <div class="portlet portlet-sortable light bordered ui-widget-content ui-resizable" style="display: block;"><div class="portlet-title ui-sortable-handle"><div class="caption font-green-sharp"><i class="icon-speech font-green-sharp"></i><span class="caption-subject bold uppercase"> FEEDBACK</span></div><div class="actions"><a href="javascript:;" class="btn btn-circle btn-default btn-sm remove"><i class="fa fa-times"></i> Remove </a><a class="btn btn-circle btn-icon-only btn-default fullscreen" href="javascript:;"></a></div></div><div class="portlet-body"><div>FEEDBACK CONTENT</div></div><div class="ui-resizable-handle ui-resizable-e" style="z-index: 90;"></div><div class="ui-resizable-handle ui-resizable-s" style="z-index: 90;"></div><div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 90;"></div></div></div> <div class="col-md-4 column sortable">

refactor to

var html =  

does not resolve the problem



via Chebli Mohamed

Laravel 5.2 UploadedFile realPath not /tmp but /public

When I upload a file to my API on vagrant everything works fine and laravel writes the file to /tmp/phpLRJnhx. When commit everything and pull the code on the live server Laravel writes the file to /var/www/webdir.nl/public. Why doesn't Laravel write the file to /tmp/ on the live server?



via Chebli Mohamed

Start learning laravel framework

I want to learn php framework, laravel. I have installed laravel 5.2 on my computer but I don't know how can I start to explore it. So, is there any recommended website for me to learn laravel framework?



via Chebli Mohamed

Sucess message is not getting displayed in laravel

I want to show a success message once the email is sent after redirected to same page. Here is my code :

return redirect('currentshowreport?showid='.$show_id)->with('success','Email sent successfully');

I am getting redirected to the specified page but the success message is not getting displayed. How to achieve this?



via Chebli Mohamed

How to pass an array from laravel to ajax

I have an array of fonts which i displaying in the page using blade templates @foreach like this

       @foreach($data as $fonts)
            <li class="abc">

                <div class="am-actions"><a href="" class="add-font"><span><i class="icon add"></i></span></a></div>
                 <a href="#" class="details">Grumpy wizards make toxic brew for the evil Queen and Jack.</a>
                </div>
                <div class="am-font-details">
                    <div class="am-font-name">{!! $fonts['font_name'] !!}</div> 
                    <div><?php echo $count = count($fonts['variants']); ?> Styles</div>
                </div>
                <div class="am-font-options">
                    <h4>SELECT VARIANTS TO INCLUDE:</h4>
                    <ul>
                        @foreach($fonts['variants'] as $variants)

                          <li><label><input type="checkbox">

                          


                          </label></li>

                        @endforeach

                    </ul>
                    <h4>LANGUAGE/SCRIPT TO INCLUDE:</h4>
                    <ul>
                        @foreach($fonts['subsets'] as $subsets)

                         <li><label><input type="checkbox"> </label></li>

                        @endforeach
                    </ul>
                </div>
            </li>
        @endforeach

as you can see i use @foreach for variants and languages inside the main loop the variants and langauges is listed with checkbox so the user can selected their choice and add. on the add the selected variants and languages with the main font array details should be passed through ajax please help me :-(



via Chebli Mohamed