From f6131ed7642817d5804d0b12e249cd5bfd2455b0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 25 Jul 2021 03:29:22 -0600 Subject: [PATCH] Update License util, add nameToId method --- app/Util/Media/License.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Util/Media/License.php b/app/Util/Media/License.php index 653013a4d..835a0acc1 100644 --- a/app/Util/Media/License.php +++ b/app/Util/Media/License.php @@ -120,4 +120,19 @@ class License { ->values() ->toArray(); } + + public static function nameToId($name) + { + $license = collect(self::get()) + ->filter(function($l) use($name) { + return $l['title'] == $name; + }) + ->first(); + + if(!$license || $license['id'] < 2) { + return null; + } + + return $license['id']; + } }