jeudi 28 septembre 2017

Laravel component Basemkhirat how to pass a collection to a blade view

I've need use Basemkhirat for rapid development write for access data on ElasticSearch.

I don't understan well, system of pagination for this component, and and so I am trying to do the work in another way.

On my controller for the index, ProposalsController@index I get a collection

$proposals = ES::type('proposals')->take(200)->get();
dd($proposals);   

Dump exit:

Collection {#436 ▼
  #items: array:200 [▼
    0 => Model {#236 ▼
      #connection: "default"
      #index: "excellenting"
      #type: "proposals"
      #casts: []
      #attributes: array:25 [▼
        "doc_id" => 40005
        "source" => "epo"
        "date" => "20080801"
        "is_demand" => false
        "tech_category" => 40700
        "country" => "TW"
        "external_doc_code" => "TW200831462A"
        "title" => "Processes suitable for producing macromolecular antioxidant compositions"
        "abstract" => "This invention relates to processes for the production of reaction mixtures, which find use as antioxidants in a variety of applications, using sterically hinde ▶"
        "requirements" => null
        "url" => null
        "trl" => array:2 [ …2]
        "interest" => "any"
        "ip_status" => "granted"
        "tech_categories" => array:3 [ …3]
        "applicants" => array:1 [ …1]
        "inventors" => array:1 [ …1]
        "references" => array:1 [ …1]
        "singularities" => array:2 [ …2]
        "main_tags" => null
        "secondary_tags" => null
        "_index" => "excellenting"
        "_type" => "proposals"
        "_id" => "CwmpXd94idHxJ4EfyNBT"
        "_score" => 1.0
      ]
      #exists: true
      #appends: []
      +"_id": "CwmpXd94idHxJ4EfyNBT"
    }
    1 => Model {#239 ▶}

For blade template, I need use #attributes of array #items.

But if I only try this, fails:

return view('proposals.index', $proposals);

Blade

@forelse ($proposals as $proposal)
   <li></li>
@empty
   <p>No fatents found</p>
@endforelse

Error

 ErrorException (E_ERROR)
Undefined variable: proposals (View: /Users/abkrim/Sites/warehouse/resources/views/proposals/index.blade.php)



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2k7p2AL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire