Welcome Guest, Not a member yet? Register   Sign In
CI4 use model's method in view
#11

You need to assign the complete model to a variable.

PHP Code:
<?php namespace App\Controllers;

use 
App\Models\ExampleModel;

class 
Example extends BaseController
{
    public function 
example()
    {
        
$exampleModel = new ExampleModel();

        
$data = [
            
'exampleModel' => $exampleModel,
        ];

        echo 
view('example'$data);
    }


You can then access it with $exampleModel->findbyid() in your view.
Reply


Messages In This Thread
CI4 use model's method in view - by pippuccio76 - 06-21-2020, 07:06 AM
RE: CI4 use model's method in view - by InsiteFX - 06-22-2020, 03:06 AM
RE: CI4 use model's method in view - by InsiteFX - 06-22-2020, 08:13 AM
RE: CI4 use model's method in view - by jreklund - 06-22-2020, 01:58 PM
RE: CI4 use model's method in view - by jinbatsu - 08-21-2020, 09:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB