Revision 728 | Revision 1693 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;class DirectoryController extends Controller{//public function index($id){$_SESSION["navigation"]["position"] = $id;$subdir = Directory::with( 'medium.medium', 'template.template', 'manufacturer' )->where( "id", $id )->firstOrFail();$dirs = Directory::with( 'medium.medium','manufacturer' )->where( "directory_id", $id )->whereIn( 'status', [0,99] )->orderBy( 'kennung' )->orderBy( 'name' )->get();$items = Item::with( 'price', 'medium.medium', 'manufacturer' )->where( "directory_id", $id )->where( 'status', '=', 0 )->get();$subdir["subdirs"] = $dirs->reject( function ( $value ){return $value->articlemaster == 1;} );$subdir["items"] = $items;$template = 'subdir';if ( $subdir->articlemaster == 1 ){$template = 'artstamm';}$artstaemmeItems = array();if ( is_countable( $subdir->template ) && isset( $subdir->template[0] ) ){$template = substr( $subdir->template[0]->template->template_value, strpos( $subdir->template[0]->template->template_value, "=" ) + 1 );}foreach ( $dirs as $dir ){if ( $dir->articlemaster == 1 ){$preise = array();$items = Item::with( 'price' )->where( "directory_id", $dir->id )->whereIn( "status", [ 0, 2 ] )->get();$dir->anz = count( $items );foreach ( $items as $item ){$preise[] = $item->price[0]->preis;}if ( $preise ){$startPrice = min( $preise );$dir->mehrerePreise = count( array_unique( $preise ) ) > 1;$dir->startpreis_tpl = $startPrice;}$subdir["items"] = $dirs->filter( function ( $value ){return $value->articlemaster == 1 && $value->anz > 0;} );/*$artstaemmeItems[$dir->id] = $dir;$artstaemmeItems[$dir->id]["items"] = Item::with( 'medium.medium', 'price', 'manufacturer' )->where( 'directory_id', '=', $dir->id )->where( 'status', '=', 0 )->get();*/}}return view( $template, ["subdir" => $subdir,"artstaemmeItems" => $artstaemmeItems,] );}}