File size: 971 Bytes
7731906
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
namespace App\Models;

class Product extends Model {
    protected $table = 'products';

    /**
     * For demonstration without a real DB table yet, 
     * we can override all() and find() or just use them once the table exists.
     */
    public function getMockProducts() {
        return [
            ['id' => 1, 'name' => 'ເສື້ອໄໝລາວ', 'price' => 250000, 'description' => 'ເສື້ອໄໝລາວຄຸນນະພາບດີ, ຜະລິດຈາກໄໝທຳມະຊາດ.'],
            ['id' => 2, 'name' => 'ສິ້ນໄໝ', 'price' => 450000, 'description' => 'ສິ້ນໄໝລາວລວດລາຍສວຍງາມ, ເໝາະສຳລັບງານບຸນ.'],
        ];
    }

    public function findMock($id) {
        $products = $this->getMockProducts();
        foreach ($products as $product) {
            if ($product['id'] == $id) return $product;
        }
        return null;
    }
}