|
|
@@ -4,6 +4,8 @@ namespace App\Http\Resources;
|
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
use App\Http\Api\UserApi;
|
|
|
+use App\Http\Api\ChannelApi;
|
|
|
+use App\Models\DhammaTerm;
|
|
|
|
|
|
class NissayaEndingResource extends JsonResource
|
|
|
{
|
|
|
@@ -15,7 +17,7 @@ class NissayaEndingResource extends JsonResource
|
|
|
*/
|
|
|
public function toArray($request)
|
|
|
{
|
|
|
- return [
|
|
|
+ $data = [
|
|
|
"id"=>$this->id,
|
|
|
"ending"=> $this->ending,
|
|
|
"lang"=> $this->lang,
|
|
|
@@ -26,5 +28,18 @@ class NissayaEndingResource extends JsonResource
|
|
|
"created_at"=> $this->created_at,
|
|
|
"updated_at"=> $this->updated_at,
|
|
|
];
|
|
|
+
|
|
|
+ $uiLang = strtolower($request->get('ui-lang','en')) ;
|
|
|
+ $term_channel = ChannelApi::getSysChannel("_System_Grammar_Term_{$uiLang}_");
|
|
|
+ if($term_channel){
|
|
|
+ $term = DhammaTerm::where("word",$this->ending)
|
|
|
+ ->where('channal',$term_channel)
|
|
|
+ ->first();
|
|
|
+ $data['term_channel'] = $term_channel;
|
|
|
+ if($term){
|
|
|
+ $data['term_id'] = $term->guid;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
}
|
|
|
}
|