I premise that I'm new to the Laravel environment.
I have this JSON file in the database
{
"48:CE:B8:09:7D:AD": ["-91"],
"70:61:91:66:6B:1E": ["-81", "-69", "-79", "-65", "-74"],
"4B:6F:42:53:EB:82": ["-84", "-73", "-81"],
"77:87:80:27:2B:31": ["-83", "-70", "-82", "-71", "-79", "-71", "-79", "-71", "-80", "-72"],
"43:FD:25:20:5A:7B": ["-76", "-84", "-76", "-88", "-77", "-86"],
"C1:04:08:03:3C:05": ["-73"],
"7F:D2:44:60:82:BD": ["-88", "-79", "-88"],
"FE:47:DA:73:90:29": ["-55", "-43", "-59", "-35", "-46", "-38", "-49"],
"62:46:58:C8:A9:9A": ["-68", "-77", "-68"],
"68:13:E4:00:12:30": ["-68", "-81"],
"4E:0D:D6:41:77:FA": ["-68", "-77", "-68", "-76", "-68", "-79", "-71"],
"71:B0:03:A6:17:A5": ["-82", "-73", "-81", "-73"],
"19:F2:64:21:35:B5": ["-74", "-65", "-77", "-69", "-78", "-69"],
"5C:D5:BA:32:06:AD": ["-86"],
"11:91:3D:57:0E:F0": ["-90", "-82"],
"44:08:E7:5C:56:B3": ["-89", "-80"],
"58:99:6F:53:65:C8": ["-77", "-85"],
"54:3C:61:D8:5B:DD": ["-88", "-79"],
"59:02:8C:78:5D:E1": ["-85", "-73", "-82", "-69", "-84", "-75", "-83", "-71"],
"64:F0:DC:95:6E:16": ["-86", "-78"],
"71:E5:42:BA:19:F4": ["-91", "-77", "-86", "-73", "-84", "-74", "-84"],
"E1:63:14:57:89:25": ["-48", "-57", "-38", "-47"],
"57:7D:E9:6F:06:24": ["-85"],
"56:B2:4B:5B:7E:2E": ["-88", "-80"],
"64:3D:02:D4:ED:4E": ["-76", "-64", "-72"],
"0C:93:8F:E5:C6:2A": ["-76", "-66"],
"3F:47:42:77:BD:9A": ["-64", "-83"],
"3C:46:5E:20:9A:FE": ["-79", "-57", "-74"],
"67:58:EE:A8:9D:CC": ["-64", "-80"],
"C4:A5:DF:24:05:7E": ["-65"],
"79:B8:3B:90:31:12": ["-89", "-71", "-88", "-75"],
"75:8E:FE:9B:69:DA": ["-93"],
"49:BE:B0:74:7A:71": ["-66", "-82"],
"55:33:20:52:E1:EC": ["-75"],
"45:D3:80:F3:A4:59": ["-79", "-71"],
"44:CA:8A:EF:31:45": ["-92", "-78"],
"5F:0D:99:F8:EE:94": ["-83"]
}
and I would like to get only some MAC addresses and respective RSSI values using Laravel. My Model is the following:
class DataFromRasp extends Model
{
use HasFactory;
public $timestamps = false;
protected $primaryKey = 'id';
protected $fillable = ['device'];
protected $casts = ['device' => 'array'];
}
And my controller:
class DataFromRaspController extends Controller
{
public function index()
{
$data=DataFromRasp::all();
return view('backend.auth.user.dictionary', compact("data"));
}
public function create()
{
}
public function store(Request $request)
{
}
public function show(DataFromRasp $dataFromRasp)
{
}
public function edit(DataFromRasp $dataFromRasp)
{
//
}
public function update(Request $request, DataFromRasp $dataFromRasp)
{
//
}
public function destroy(DataFromRasp $dataFromRasp)
{
//
}
public function getDict(Request $request)
{
$data = $request->get('jsondata');
$data = json_decode($data, true);
DataFromRasp::create(['device' => $data]);
return back()->with('success', 'Data successfully store in json format.');
}
}
The getDict() function receives the JSON from a raspberry and saves it in the DB.
The structure of the DB table is as in figure https://i.stack.imgur.com/IeLvM.jpg
I need the values of the MAC addresses "E1:63:14:57:89:25" and "FE:47:DA:73:90:29", how can I get them?